▲ | rimunroe a day ago | |
What's the condition in which you're trying to focus that input? Usually you're doing that in response to some sort of user action, in which case the time to handle that is within an event handler. > And the idea is (I assume?) that the DOM is the external system! This absolutely bonkers! The DOM is my app! External systems usually means stuff like an event system, network requests, or something else not managed directly by React. Unless you're reaching outside the area of the DOM React is managing, you can usually do this in event handlers or (for spookier cases) ref callbacks. There are certainly exceptions, but it's often an architectural smell. Further down in the docs you'll see[0]: > Effects are an “escape hatch”: you use them when you need to “step outside React” and when there is no better built-in solution for your use case. [0] https://react.dev/reference/react/useEffect#wrapping-effects... |