Unavoidable eslintreact-hooks/exhaustive-deps warning after restoring scroll position from session storage #22414
Labels
Component: ESLint Rules
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
My implementation for restoring scroll position after route change goes like this:
I had to omit
storedScroll
from dependencies of firstuseEffect
since I do want "restoring" to be triggered only when route changes.I went through entire https://reactjs.org/docs/hooks-faq.html#is-it-safe-to-omit-functions-from-the-list-of-dependencies section and got encourage by docs to create this issue although I don't see any alternative implementation that wouldn't fire warning.
At the end,
storedScroll
is dependent onsessionStorage
not state nor props (although internally inuseSessionStorage
it is stored as state).The text was updated successfully, but these errors were encountered: