For Class component version this.setState({ count: value }); you are changing the "reference". For the Function Component, you are changing the primitive, thus the component doesn't re-render.
React re-renders as states change. States change when a "reference" change. Primitive values are stored in stack. This leads understanding of JS.
Nice demos there~
It's a confusing concept well-demonstrated.
For Class component version
this.setState({ count: value });
you are changing the "reference". For the Function Component, you are changing the primitive, thus the component doesn't re-render.React re-renders as states change. States change when a "reference" change. Primitive values are stored in stack. This leads understanding of JS.
For more info on how FC & CC differ check out
overreacted.io/how-are-function-co...
thanks Sung really helpful article
You're welcome :)
Dan's article's are long but well written and thorough.