paragon icon indicating copy to clipboard operation
paragon copied to clipboard

[sanity check] `PropTypes.oneOfType([PropTypes.element, PropTypes.func])` replaced with `PropTypes.elementType`

Open adamstankiewicz opened this issue 1 year ago • 2 comments

Example component where issue is seen:

DataTable supports a columns prop that allows consumers to customize their table's column configuration. For each column, consumers may override the Cell property within react-table to customize the display and bring in custom UI elements / formatting.

Currently, the Cell property accepts a prop type similar to PropTypes.oneOfType([PropTypes.element, PropTypes.func]). However, this does not support passing an element type, i.e. just the component name.

<DataTable
  columns={[
    {
      id: 'testColumn',
      Cell: TestTableColumnCell,
    },
  ]}
/>

where TestTableColumnCell might be the following, for example:

function TestTableColumnCell({ row }) {
  return `${row.original.firstName} ${row.original.lastName}`;
}

adamstankiewicz avatar Oct 20 '23 13:10 adamstankiewicz

https://github.com/openedx/paragon/pull/2749

monteri avatar Oct 31 '23 10:10 monteri

@PKulkoRaccoonGang please check other components for the same issue

viktorrusakov avatar Dec 21 '23 10:12 viktorrusakov