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
State values in React are generally held and memoized across renders by one of two hooks: useRef() and useState(). There exists one salient functional difference in use cases:
useState() will trigger a DOM refresh when its value changes (per React's differencing library)
useRef() will not trigger a DOM refresh when its value changes
There are a number of places in the app where a value is being memoized in a useState() hook but for one reason or another, do not need to trigger a DOM refresh. We should review all instances of useState() in the app and refactor to for useRef() where warranted. This will reduce unnecessary DOM refreshes and make the app more performant in general.
The text was updated successfully, but these errors were encountered:
What is needed?
State values in React are generally held and memoized across renders by one of two hooks:
useRef()
anduseState()
. There exists one salient functional difference in use cases:useState()
will trigger a DOM refresh when its value changes (per React's differencing library)useRef()
will not trigger a DOM refresh when its value changesThere are a number of places in the app where a value is being memoized in a
useState()
hook but for one reason or another, do not need to trigger a DOM refresh. We should review all instances ofuseState()
in the app and refactor to foruseRef()
where warranted. This will reduce unnecessary DOM refreshes and make the app more performant in general.The text was updated successfully, but these errors were encountered: