useSelector question #1785
-
Hey, example: const firstNameError = useSelector(errorsAtoms , (errors) => errors.firstName); When I have tree like that Form
When the the secondName fails validation during submit and now errorsAtoms is like so: Will it rerender FirstName component? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
No. I think it work as you expect. useSelector is a bit old, current recommendation would be simply deriving atoms: const errorsAtom = atom({ firstName: "", secondName: "", lastName: "" })
const firstNameErrorAtom = atom((get) => get(errorsAtom).firstName);
const secondNameErrorAtom = atom((get) => get(errorsAtom).secondName);
const lastNameErrorAtom = atom((get) => get(errorsAtom).lastName); |
Beta Was this translation helpful? Give feedback.
No. I think it work as you expect.
useSelector is a bit old, current recommendation would be simply deriving atoms: