Environment
- react: 18.2
- jotai: 2.2 (latest)
Problem
const ParentComponent = () => {
const [val, setVal] = useState(0);
return <ChildComponent val={val} />;
}
const myAtom = atom(0);
const ChildComponent = ({ val }) => {
// I want to sync [val -> myAtom]
};
const Child_ChildComponent = () => {
const valFromAtom = useAtomValue(myAtom);
...
};
Should I make new atom every re-render to sync with props ?
useHydrateAtoms
did not working.