G
G
Gary_Ihar2021-08-13 15:09:55
React
Gary_Ihar, 2021-08-13 15:09:55

When can shouldComponentUpdate still render?

I do it like this:

shouldComponentUpdate(nextProps, nextState) {
    return false;
}

The component still renders. There are more than 1000 props and lines in the component, I don’t give all the code. I read in the documentation that
Currently, if shouldComponentUpdate() returns false, then UNSAFE_componentWillUpdate(), render(), and componentDidUpdate() will not be called. In the future, React may treat shouldComponentUpdate() as a hint rather than a strict directive. In such a case, returning false can cause the component to re-render.


How do you know when shouldComponentUpdate is taken as a recommendation and when as a rule?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandroppolus, 2021-08-13
@Alexandroppolus

Maybe forceUpdate is called somewhere, it works past shouldComponentUpdate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question