未捕获的TypeError:无法读取react-redux-grid中未定义的属性“map”

时间:2017-04-02 10:30:09

标签: reactjs tree grid redux

我想通过react-redux-grid创建一个树Grid。但是我得到了错误:Uncaught TypeError:无法读取未定义的属性“map”。

我按照https://github.com/bencripps/react-redux-grid/blob/master/docs/USING_TREE.md

的说明进行了操作

不确定出了什么问题,代码如下:

import { Grid } from 'react-redux-grid';
export const Tree = ({ store }) => {
const dataSource = {
      data: [
        {
            id: 11,
            parentId: 1,
            name: 'Category 11',
            editable: false,
            leaf: true,
            categoryCode: '12jf-3h3h-11'
        }
      ],
      partial: true
}

const data = {
    root: {
        id: -1,
        parentId: null,
        children: [
            {
                id: 1,
                parentId: -1,
                name: 'Category 1',
                categoryCode: 'as-ffw-34neh-',
                editable: true,
                children: [
                    {
                        id: 12,
                        parentId: 1,
                        leaf: false // there are children for this record that haven't been fetched yet
                        // ... rest of data
                    },
                    {
                        id: 13,
                        parentId: 1
                        // ... rest of data
                    }
                ]
            }
        ]
    }
}

const treeConfig = {
    stateKey: 'tree-grid-1',
    gridType: 'tree', // either `tree` or `grid`,
    showTreeRootNode: false, // dont display root node of tree
    columns: [
        {
            dataIndex: 'category',
            name: 'Category',
            expandable: true // this will be the column that shows the nested hierarchy
        },
        {
            dataIndex: 'categoryCode',
            name: 'Category Code',
            expandable: true // can be set on multiple columns
        },
        {
            dataIndex: 'editable',
            name: 'Editable',
            expandable: false // will be displayed as flat data
        }
    ],
    data: data
    dataSource: dataSource
};

    return (
    <Grid { ...treeConfig } />
    );
}

//another page
let React = require('react');
import thunk from 'redux-thunk';
import Tree from '../Tree.jsx';
const reducers = {
 //some reducers here
}
const store = createStore(reducer,applyMiddleware(thunk));
 let gridPage = React.createClass({
 render: function() {
  return(
   <Provider store={store}>
    <Tree store={store} />
   </Provider>
  )
}
});

0 个答案:

没有答案