Skip to content
Advertisement

How to pass props to a component which is being passed as value

here is my code scenario

const components = {
    body: {
      row: EditableFormRow,
      cell: EditableCell,
    },
  };

I am using components in another component like below.

<CustomTable
    columns={updatedcolumns}
    dataSource={dataSource}
    components={components}
    rowClassName={() => 'editable-row'}
    bordered
    size="middle"
    pagination={false}
    // scroll={{ x: '130%', y: 240 }}
  />

I want to pass a prop to EditableCell which is a component defined in another file. when I do following it gives me error

const components = {
    body: {
      row: EditableFormRow,
      cell: <EditableCell type="text"/>,
    },
  };

I am not sure how do I pass props. Please help.

Advertisement

Answer

You need to wrap the component in a function:

  cell: () => <EditableCell type="text"/>,
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement