我正在尝试实现一个简单的数据表,如作者在此处的示例所示:示例
...
export default class TableExample extends Component {
static contextTypes = {
list: PropTypes.instanceOf(Immutable.List).isRequired
};
...
我试图将 ImmutableJS 列表作为属性传递,但无济于事。还有什么我在这里想念的吗?
如何将数据数组放入组件中?
呈现表格示例的父组件如下所示:
render() {
const list = fromJS(this.props.data);
console.log(typeof(list)); //this outputs "object"
console.log(list); // this outputs ImmutableJS list with size of 761
return (
<TableExample list={list}/>
)
}
我还尝试更改从 this.context 链接到 this.props 的 TableExample 中 { list } 的所有声明,但没有取得多大成功。任何帮助将不胜感激。
此时 Chrome 返回的控制台错误:
Warning: React.createElement: type is invalid -- expected a string (for
built-in components) or a class/function (for composite components) but
got: undefined. You likely forgot to export your component from the
file it's defined in. Check the render method of `TableExample`.