react-datasheet icon indicating copy to clipboard operation
react-datasheet copied to clipboard

PropTypes settings: func vs class

Open ririvas opened this issue 5 years ago • 2 comments

Hi,

I'm getting a warning that my react component passed to the valueViewer setting is not a func.

Warning: Failed prop type: Invalid prop `valueViewer` of type `object` supplied to `DataCell`, expected `function`.

See below: this is because valueViewer has the propType set to func (along with other props). Should this be expanded to encompass react classes as well (i.e. any react component)?

DataSheet.propTypes = {
  data: PropTypes.array.isRequired,
  className: PropTypes.string,
  overflow: PropTypes.oneOf(['wrap', 'nowrap', 'clip']),
  onChange: PropTypes.func,
  onCellsChanged: PropTypes.func,
  onContextMenu: PropTypes.func,
  onSelect: PropTypes.func,
  isCellNavigable: PropTypes.func,
  selected: PropTypes.shape({
    start: PropTypes.shape({
      i: PropTypes.number,
      j: PropTypes.number
    }),
    end: PropTypes.shape({
      i: PropTypes.number,
      j: PropTypes.number
    })
  }),
  valueRenderer: PropTypes.func.isRequired,
  dataRenderer: PropTypes.func,
  sheetRenderer: PropTypes.func.isRequired,
  rowRenderer: PropTypes.func.isRequired,
  cellRenderer: PropTypes.func.isRequired,
  valueViewer: PropTypes.func,
  dataEditor: PropTypes.func,
  parsePaste: PropTypes.func,
  attributesRenderer: PropTypes.func,
  keyFn: PropTypes.func
}

ririvas avatar Mar 03 '20 16:03 ririvas

Happy to create a pull request

ririvas avatar Mar 19 '20 01:03 ririvas

This also causes warnings for functional components wrapped in React.memo.

JustWalters avatar Jun 25 '20 00:06 JustWalters