Why setting state to same value executes the body of the component?
here is the demo: https://codesandbox.io/s/react-fake-render-lcrcpd
- Why setting the state to the same value "t" causes "rerender"?
- Why console.log in the body of the component logs 3, but the rendered value is 2?
- Why the effect without dependency does not get triggered when the log in the body shows 3?
- Does that mean it is not safe to update ref's value directly in the body of the component?
First time clicking the button displays render count 2 -> 4, it skips 3, because it is the previous known value, but not the one that is rendered