fgerschau / comments

1 stars 0 forks source link

react-component-composition/ #25

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

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/

allbertuu commented 1 year ago

What an awesome article! Thanks, bro, all of this concept was well-explained and simple to understand. Keep it up!

devbyishtiaq commented 1 year ago

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?

allbertuu commented 1 year ago

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.

1ucasdev commented 10 months ago

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!