-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird interaction when working with 'react-sortable-hoc' #709
Comments
This creates a new function prop each time you render: rowHeight={({ index }) => 50} That's sufficient to trigger a re-render of the child component, even if no other properties changed. In this case, you could pass a small attribute that changes each time sort order changes (eg an incremented counter) to let the component know to re-render. Check out the section on "pure components" in the docs for more info. |
@bvaughn I have to do a lot more than sorting, all CRUD on items, I'm using redux, so the list of task can be read from redux store as array of tasks
I add state
my question is, is this a burden for performance? How do I improve? |
Any time your data changes, you need to re-render the list, right? There's no way around this. You don't need to use a counter. Actually if you have something in the data that changes, it's probably even better to just pass it through (eg a prop like I spent a lot of effort optimizing react-virtualized. Re-rendering isn't that expensive since it's only rendering a slice of the rows. |
https://codesandbox.io/s/qYEvQEl0
So I wrote a demo myself that didn't work compare to one sample that works, the only difference being one props for
<List/>
rowHeight={({ index }) => 50}
rowHeight={50}
I use the latter way. And it is not working. Why?
The text was updated successfully, but these errors were encountered: