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
{{ message }}
Repository navigation
Rename useCallbackOncePerRender to useCallbackOnce #542
useCallbackOncePerRender runs the callback once until deps change, not once per render, so the name suggests the opposite of what it does.
Add useCallbackOnce with the same signature and behavior, and mark useCallbackOncePerRender as deprecated.
Rewrite the JSDoc description to say the callback runs once until deps change, and fix @param {() => void} callback, which also accepts functions with arguments.
Fix the second example. The returned function keeps the same reference, so useEffect(() => trackUserVisit(), [trackUserVisit]) does not run again when userId changes. Add userId to the dependency list.
Activity