You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure that each custom hook is concurrent-mode safe. This requires following certain principles, such as:
avoiding reading or writing refs during the render process.
When using external state management libraries, useSyncExternalStore must be used. However, this usually doesn't concern us as we generally don't store setState.
Given that stable event handler hooks would only have incorrect values when read within a child component's useLayoutEffect, I believe we can temporarily ignore this scenario and uniformly wrap translated event handlers with useEvent.
functionExample(props){constcallback=useDynamicCallback(props.callback);return<Childcallback={callback}/>;}functionChild({ callback }){useLayoutEffect(()=>{// Child effects are run before parent effects!// This means the callback ref has not yet been updated-// which means that it still points to the previous version,// with stale values and potentially different behavior.// This function call will probably cause problems!callback();},[]);}
Why not just make all hooks that are not compatible with concurrent mode yet compatible on top of the main branch and then releasing everything together as v6?
It depends on the v5 version with any new features or modifications. I'm mainly still thinking about supporting concurrent mode, where else does our code need to be changed to support, and if there are not too many changes, there is no need to pull a v6 branch
references:
facebook/react#16956 (comment)
facebook/react#18003 (comment)
The text was updated successfully, but these errors were encountered: