A bare closure would always see the latest values because it closes over them during render. And the latest useEffect closure will have closed over that method..
Here is the test suite for useEffectEvent and the test ensuring it does not provide a stable reference: https://github.com/facebook/react/blob/main/packages/react-r...
Re:React: You Might Not Need an Effect
by andrewingram on Thursday March 23, 2023 @08:12AM
(#35273483)
You're right, i'll redact/edit. Hm, this doc page is exceptionally confusing.
> Here, onConnected is called an Effect Event. It’s a part of your Effect logic, but it behaves a lot more like an event handler. The logic inside it is not reactive, and it always “sees” the latest values of your props and state.