TypeError: Cannot read property 'object' of undefined
Hello, I'm getting error when follow the usage readme:
firstly i install sematable with npm i sematable
and create component like:
import React, { Component, PropTypes } from 'react';
import sematable, { Table } from 'sematable';
import AppsTableActions from './AppsTableActions';
const columns = [
{ key: 'id', header: 'ID', sortable: true, searchable: true, primaryKey: true },
{ key: 'name', header: 'Application', sortable: true, searchable: true },
{ key: 'token', header: 'Token' },
{ key: 'plan', header: 'Plan', sortable: true },
{ key: 'role', header: 'Role', sortable: true },
{ key: 'actions', header: 'Actions', Component: AppsTableActions },
];
const propTypes = {
headers: PropTypes.object.isRequired,
data: PropTypes.array.isRequired,
primaryKey: PropTypes.string.isRequired,
};
class AppsTable extends Component {
render() {
return (
<Table
{...this.props}
selectable
columns={columns}
/>
);
}
}
AppsTable.propTypes = propTypes;
export default sematable('allApps', AppsTable, columns);
then created action:
import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router-dom';
const propTypes = {
row: PropTypes.object.isRequired,
};
class AppsTableActions extends Component {
render() {
const row = this.props.row;
return (
<Link to={`/settings/${row.id}`}>
Settings
</Link>
);
}
}
AppsTableActions.propTypes = propTypes;
export default AppsTableActions;
and getting this error:
4 |
5 | const propTypes = {
> 6 | row: PropTypes.object.isRequired,
7 | };
8 |
9 | class AppsTableActions extends Component {
i already installed propTypes with npm.
what's wrong ?
Hi @cihanzengin. Can you try importing PropTypes from prop-types package instead? You are probably using a newer version of react than what our docs refer to?
So just use import PropTypes from 'prop-types'
Hi @cihanzengin. Can you try importing
PropTypesfromprop-typespackage instead? You are probably using a newer version of react than what our docs refer to?So just use
import PropTypes from 'prop-types'
Thanks it's worked i think :) because i got new error:
TypeError: Cannot read property 'forEach' of undefined
(anonymous function)
node_modules/sematable/lib/selectors.js:229
226 | }
227 | }); // collect values for columns that don't have predefined values
228 |
> 229 | initialData.forEach(function (row) {
The data prop is required, it cannot be undefined.
The
dataprop is required, it cannot be undefined.
sorry i'm newbie, where exactly place data prop? and how exactly it's will look?