B
B
beefront172019-03-01 17:27:35
React
beefront17, 2019-03-01 17:27:35

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

2 answer(s)
A
Anton Spirin, 2019-05-01
@beefront17

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

P
Pavlo Ponomarenko, 2019-03-01
@TheShock

Maybe you don't specify key ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question