Ref is a reserved property on build-in primitives, where React will store the DOM node after it was rendered. It will be set back to null when the component is unmounted. The linter won't complain about adding it to the dependency array, and the ref is also not read during render. The effect will run once "on mount" (twice in

8m read timeFrom tkdodo.eu
Post cover image
Table of contents
Interacting with refs .css-1bw77fa{color:var(--theme-ui-colors-primary);-webkit-text-decoration:none;text-decoration:none;}.css-1bw77fa:hover{-webkit-text-decoration:underline;text-decoration:underline;}Callback refs
3 Comments

Sort: