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
useFocusZone accepts an uncommon optional second argument: an array of dependencies. While comparable to the dependency arrays passed to other React hooks, the optionality and unlinted nature of this argument make it easy to forget about or incorrectly configure. I have personally introduced a few bugs because I didn't know this argument needed to be considered.
I think with modern JavaScript this array is probably wholly unnecessary. All options passed to useFocusZone through the options object can easily be included as dependencies by using a shallow comparison. The trickier part is for the hook to know when the contents of the container element change, but this can now relatively easily be achieved by using a MutationObserver on the parent.
With MutationObserver, the dependencies array could be totally removed. This would simplify the API and clear up a potential footgun.
The text was updated successfully, but these errors were encountered:
useFocusZone
accepts an uncommon optional second argument: an array of dependencies. While comparable to the dependency arrays passed to other React hooks, the optionality and unlinted nature of this argument make it easy to forget about or incorrectly configure. I have personally introduced a few bugs because I didn't know this argument needed to be considered.I think with modern JavaScript this array is probably wholly unnecessary. All options passed to
useFocusZone
through the options object can easily be included as dependencies by using a shallow comparison. The trickier part is for the hook to know when the contents of the container element change, but this can now relatively easily be achieved by using aMutationObserver
on the parent.With
MutationObserver
, the dependencies array could be totally removed. This would simplify the API and clear up a potential footgun.The text was updated successfully, but these errors were encountered: