-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
VirtualizedList- inefficient function passing for CellRenderer #20174
Comments
Thank you reporting this issue. It would be great if you could open a PR 👍 |
@jasekiw Do you want to open a PR for this issue? |
@VahidBo Yes, I just committed some code. I will need to get the tests running before I feel comfortable making a pr. |
@VahidBo How do I test my local react-native with a project? I tried npm link but when I run npm start which calls
react-native info
|
@jasekiw Usually when I want to test my codes on a open-source project, first I init a project and then apply my change on the codes of open-source project that I want to contribute on it (actually I change the codes on node_modules folder) and then I test my changes. I can't say that it is the best solution to do what you want but it usually works for me. |
@VahidBo I was able to get that to work. I found out that there is another issue that is causing the CellRenderer to re-render.
the parentProps is not equal by reference which causes a re-render. I'm not sure how I can get around this while also having it render when needed. Maybe do a shallow comparison of the props in a shouldComponentUpdate method? Any thoughts? |
@VahidBo I'm thinking the solution is to pull in the shallowEqual algorithm and modify it to allow for exclusions. I would exclude the parentProps and then perform a shallow equal on the parentProps. What do you think of this approach? |
@VahidBo I found out what's going on. When any component is passed to the parent, It always receives a new reference thus causing props to change. It looks like the props that have components being passed in are ItemSeparatorComponent As far as I can tell the CellRenderer only cares about ItemSeparatorComponent which is already passed as a prop. This means I need to exclude all of these in the parent props to allow the CellRenderer to only render when needed. Is this logic right? I think I am close to submitting a pr. |
@jasekiw Sorry for late replay, I did not work on |
Any updates ? |
There have been multiple PR's opened for this. The one that is currently opened is I believe they are waiting for a review and merge from the React Native team. |
Summary: This is VirtualList Optimization done by christianbach in facebook#21163 enabled behind a prop: `experimentalVirtualizedListOpt` with backward compatibility. Fixes facebook#20174 based of jasekiw pull request facebook#20208 ## Changelog // TODO: [CATEGORY] [TYPE] - Message Pull Request resolved: facebook#27115 Test Plan: // TODO: Add tests related to backward compatibility. (Will need help) Differential Revision: D30095387 Pulled By: lunaleaps fbshipit-source-id: 1c41e9e52beeb79b56b19dfb12d896a2c4c49529
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Environment
Run
react-native info
in your terminal and paste its contents here.Description
I used the npm package why-did-you-update to help optimize my components and prevent re-renders. However there is a re-render that I cannot control. This happens for every item in the list. My gues
It seems this is caused by an anonymous function at
react-native/Libraries/Lists/VirtualizedList.js
Line 691 in d756d94
I propose that this function be defined on the class to prevent unnecessary re-renders.
The text was updated successfully, but these errors were encountered: