React Hooks useState+useEffect+event gives stale state
value is stale in the event handler because it gets its value from the closure where it was defined. Unless we re-subscribe a new event handler every time value changes, it will not get the new value. Solution 1: Make the second argument to the publish effect [value]. This makes the event handler get the … Read more