facebookarchive / fixed-data-table

A React table component designed to allow presenting thousands of rows of data.
http://facebook.github.io/fixed-data-table/
Other
4.3k stars 553 forks source link

Unknown props `onSortChange`, `sortDir` on <div> tag. #453

Open jibees opened 8 years ago

jibees commented 8 years ago

Hi, Just see a React warning when using the last version of fixed-data-table (ie. 0.6.3) and React (ie. 15.3.1)

Unknown props 'onSortChange', 'sortDir' on <div> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop
in div (created by FixedDataTableCellDefault)
...

Thanks !

KamranAsif commented 7 years ago

Hmm this might be a bug in your code. Can you paste the full stacktrace?

jibees commented 7 years ago

Yes, sure:

console.js:26Warning: Unknown props 'onSortChange','sortDir' on <div> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop
    in div (created by FixedDataTableCellDefault)
    in FixedDataTableCellDefault (created by SortHeaderCell)
    in SortHeaderCell (created by ContentDBApp)
    in div (created by FixedDataTableCell)
    in FixedDataTableCell (created by FixedDataTableCellGroupImpl)
    in div (created by FixedDataTableCellGroupImpl)
    in FixedDataTableCellGroupImpl (created by FixedDataTableCellGroup)
    in div (created by FixedDataTableCellGroup)
    in FixedDataTableCellGroup (created by FixedDataTableRowImpl)
    in div (created by FixedDataTableRowImpl)
    in div (created by FixedDataTableRowImpl)
    in FixedDataTableRowImpl (created by FixedDataTableRow)
    in div (created by FixedDataTableRow)
    in FixedDataTableRow (created by FixedDataTable)
    in div (created by FixedDataTable)
    in div (created by FixedDataTable)
    in FixedDataTable (created by TransitionTable)
    in TransitionTable (created by ContentDBApp)
    in div (created by ContentDBApp)
    in div (created by ContentDBApp)
    in div (created by ContentDBApp)
    in ContentDBApp

ContentDBApp is my component

wcjordan commented 7 years ago

@jibees I'm assuming you're making use of the SortHeaderCell example code. This bug appears to be in there. Where it consumes the props, it doesn't consume onSortChange when it should. It does appear to consume sortDir though so I'm not sure why you're seeing that as an error, unless it's fixed on FDT2 but not FDT.

Adding onSortChange to be consumed in that SortHeaderCell should fix the issue. If that works for you we'd appreciate it if you could put up a PR with the fix to the example on our repo here. Thanks!

wcjordan commented 7 years ago

I've fixed this in the FDT2 examples with this PR: https://github.com/schrodinger/fixed-data-table-2/pull/59

roblapp commented 7 years ago

This is still an issue. I am having this problem as well. I am not sure what @wcjordan meant by 'Adding onSortChange to be consumed in that SortHeaderCell should fix the issue'. Do he mean to move the _onSortChange function from the SortExample class to the SortCellHeader class?

wcjordan commented 7 years ago

Here's an example

var {onSortChange, sortDir, children, ...props} = this.props;
return <Cell {...props}>
...

The examples in this repo are unfortunately out of date. I recommend copying from the maintained fork. See here for a complete example: https://github.com/schrodinger/fixed-data-table-2/blob/master/examples/SortExample.js

roblapp commented 7 years ago

@wcjordan Ah I see. Thanks for showing me that.