Open utterances-bot opened 1 year ago
What an awesome article! Thanks, bro, all of this concept was well-explained and simple to understand. Keep it up!
I have a confusion. So, a react component rerenders when any of it's state changes. And, if the component rerenders, it's child components will rerender as well. In you example, the state of the parent component "PostLayout" is being changed which will cause it to rerender. So, as it is wrapping "Post" component which is a child component to it, it should also rerender the "Post" component. Doesn't it?
I have a confusion. So, a react component rerenders when any of it's state changes. And, if the component rerenders, it's child components will rerender as well. In you example, the state of the parent component "PostLayout" is being changed which will cause it to rerender. So, as it is wrapping "Post" component which is a child component to it, it should also rerender the "Post" component. Doesn't it?
Hi, Friend! As a matter of fact, in the example PostLayout isn't wrapping the Post component, but being wrapped by Post. And what if I misunderstood and you've already known that, be clear that Post won't be rerendered 'cause it's PostLayout's parent and nothing has to do with its own render cycle, even if the children of PostLayout has changed.
Thanks for the detailed information! So far I’ve figured out how to make an calculator with history. I will continue to learn new technologies. Thank you!
React Component Composition Explained | Felix Gerschau
Learn how to use component composition to organize your code and improve performance.
https://felixgerschau.com/react-component-composition/