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
Currently React requires an empty dependency array to use an effect only on components' initial render.
This frequently causes confusion for new React developers that could be remedied with the addition of a unique named hook that handles this case. Adheres to a design principle that says "Names should specify their intent, if a function or variable requires documentation then its name does not specify its intent".
// Requires the developer to know what this does either through prior trial and error, or prior learning.// Often mistakenly interpreted by new developers as an effect that will run every render.useEffect(()=>{},[])// Name provides the intent. Developer can interpret behavior without framework specific knowledge.useOnLoadEffect(()=>{});
This could provide clarity for React applications. Upon implementation, could potentially provide hinting to use the new hook when an empty array is detected to remain backwards compatible. Same logic could be applied for useMemo.
useOnLoadMemo(()=>{});
The text was updated successfully, but these errors were encountered:
Currently React requires an empty dependency array to use an effect only on components' initial render.
This frequently causes confusion for new React developers that could be remedied with the addition of a unique named hook that handles this case. Adheres to a design principle that says "Names should specify their intent, if a function or variable requires documentation then its name does not specify its intent".
This could provide clarity for React applications. Upon implementation, could potentially provide hinting to use the new hook when an empty array is detected to remain backwards compatible. Same logic could be applied for useMemo.
The text was updated successfully, but these errors were encountered: