Capítulo 20 de 39
setFocus(name, { shouldSelect? }) programmatically focuses a registered input by invoking the ref's focus() method.
ref was actually attached during register — nothing to focus otherwise.reset(): reset removes all input references, so a setFocus call immediately after has nothing to focus.useEffect(() => {
setFocus("firstName")
}, [setFocus])
setFocus immediately after reset(): the refs reset just cleared aren't there anymore.Controller whose target component doesn't forward refs): nothing happens.setFocus needs the field to be registered with a real DOM ref.reset().setFocus uses.shouldFocusError is the automatic, validation-driven counterpart of manually calling setFocus.