Answer the question
In order to leave comments, you need to log in
How to avoid react rerender?
Good afternoon! Please tell me how to make a gradual rendering so that there is no re-rendering? React
project .
For example, now, after a certain interval, I push elements to the state and from the state I already render the elements. But in this case, the re-render of the elements that are already in the array.
The question is how to make it so that only new elements from the array are rendered?
Perhaps there is something with react 16.*
I will be grateful for the help
Answer the question
In order to leave comments, you need to log in
Options:
1. Specify the key property if not specified.
2. Wrap the elements in a connect call from the react-redux package . This will prevent re-rendering if the props haven't changed.
3. Use PureComponent .
4. Implement the shouldComponentUpdate method in the list elements .
5. Check that when the state is updated, the objects passed to the list elements are not recreated. That is, the condition is met:prevProp === prop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question