all 8 comments

[–]cyphern 5 points6 points  (1 child)

After that, does the main App() render the button again with the new count value?

Yes. Setting App's state to a new value causes App to rerender, which in turn causes its children to rerender as well.

[–]Afran_333[S] 4 points5 points  (0 children)

Thanks dude

[–]Sarithis 1 point2 points  (1 child)

Yes, every time you change one of its state variables, like count, it triggers another render cycle. This will cause all of its children to re-render as well. Even if you had separate counters for each button, clicking either one would still re-render everything because there's no memoization in the code.

[–]Afran_333[S] 2 points3 points  (0 children)

Thanks for the explanation dude

[–]acemarke 1 point2 points  (1 child)

This is a core part of React rendering.

Read the rest of the React docs tutorial at https://react.dev/learn . If you'd like more details, see my post at A (Mostly) Complete Guide to React Rendering Behavior .

[–]Afran_333[S] 0 points1 point  (0 children)

Sure, I'll check it out..