What is alternative way to handle input's focus? #9794
Unanswered
constantinehuzenko
asked this question in
Q&A
Replies: 1 comment
-
Why don't you use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to find the best way to handle focus for a Remix app. The common approach is using useEffect, as shown in this example:
remix/examples/newsletter-signup/app/routes/newsletter.tsx
Lines 46 to 60 in 9b46b90
The main reason I don't like this method is because when performing validation and focusing through an action, there is a brief loading state before the validation error/focusing occurs, even though no actual network request has been sent.


My solution is to use
useFetcher
and do validation/focuses on form submit, if validation passed I'm sendingclean
data to action. Do you think is it good approach? Can somebody share their experience handling focus?Beta Was this translation helpful? Give feedback.
All reactions