# Avoiding useEffect with callback refs

DevFeed: [Avoiding useEffect with callback refs](<https://devfeed.tech/articles/avoiding-useeffect-with-callback-refs-48178.md>)

Original publisher: [Read original article](<https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs>)

Published: 2022-08-14T00:00:00Z

Content type: tutorial

Language: en

Sources: [TkDodo](<https://devfeed.tech/sources/tkdodo-s-blog.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [callback](<https://devfeed.tech/topics/callback.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>)

Tags: [callback](<https://devfeed.tech/tags/callback.md>), [effect](<https://devfeed.tech/tags/effect.md>), [react](<https://devfeed.tech/tags/react.md>), [refs](<https://devfeed.tech/tags/refs.md>), [render](<https://devfeed.tech/tags/render.md>), [user-interaction](<https://devfeed.tech/tags/user-interaction.md>)

## AI overview

This tutorial explains why callback refs can be preferable to useEffect for actions that should occur when a DOM node is rendered, such as focusing an input. It describes how effects can run before a conditionally rendered node exists and therefore fail to focus it.

## Source excerpt

Interacting with DOM nodes doesn't necessarily need useEffect