Answer the question
In order to leave comments, you need to log in
When to use React.memo?
I read the documentation, React.memo is a PureComponent for functional components, but why is it almost never used?
Logically, every component (without its own state), even those that do not use props, should be wrapped in a memo, but they don’t do that, why?
I can’t find a definitive answer yet, I’ll be grateful for a hint:
when changing the state of a component, does React re-render starting from the component whose state has changed, or the entire tree from the root?
Answer the question
In order to leave comments, you need to log in
But why isn't it being used?
(no own state)
Logically, every component (without its own state), even those that do not use props, should be wrapped in a memo, but they don’t do that, why?
<MemoComp onClick={() => console.warn('hello')} />
<MemoComp isActive={item || isEnabled} />
memo stores each component in memory, respectively, the more stored components, the more memory is occupied
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question