如何将道具传递给作为值传递的组件
How to pass props to a component which is being passed as value
这是我的代码场景
const components = {
body: {
row: EditableFormRow,
cell: EditableCell,
},
};
我正在另一个组件中使用组件,如下所示。
<CustomTable
columns={updatedcolumns}
dataSource={dataSource}
components={components}
rowClassName={() => 'editable-row'}
bordered
size="middle"
pagination={false}
// scroll={{ x: '130%', y: 240 }}
/>
我想将一个道具传递给 EditableCell,它是另一个文件中定义的组件。
当我跟随它时,它给我错误
const components = {
body: {
row: EditableFormRow,
cell: <EditableCell type="text"/>,
},
};
我不知道如何传递道具。请帮忙。
您需要将组件包装在一个函数中:
cell: () => <EditableCell type="text"/>,
cell: (props) => <EditableCell type="text" {...props}/>
这是我的代码场景
const components = {
body: {
row: EditableFormRow,
cell: EditableCell,
},
};
我正在另一个组件中使用组件,如下所示。
<CustomTable
columns={updatedcolumns}
dataSource={dataSource}
components={components}
rowClassName={() => 'editable-row'}
bordered
size="middle"
pagination={false}
// scroll={{ x: '130%', y: 240 }}
/>
我想将一个道具传递给 EditableCell,它是另一个文件中定义的组件。 当我跟随它时,它给我错误
const components = {
body: {
row: EditableFormRow,
cell: <EditableCell type="text"/>,
},
};
我不知道如何传递道具。请帮忙。
您需要将组件包装在一个函数中:
cell: () => <EditableCell type="text"/>,
cell: (props) => <EditableCell type="text" {...props}/>