[2.11.1] Derived atom is not re-evaluated if it read between multiple set #2959
-
Bug DescriptionIn the code below, the value of This problem occurs in v2.11.1 but not in v2.11.0. I suspect it may be a regression introduced by the fix for #2906. Any advice would be appreciated. import { atom, useAtomValue, useSetAtom } from "jotai";
const countAtom = atom(0);
const countDerivedAtom = atom((get) => get(countAtom));
const countUpAtom = atom(undefined, (get, set) => {
set(countAtom, 1);
get(countDerivedAtom);
set(countAtom, 2);
});
function App() {
const countUp = useSetAtom(countUpAtom);
const count = useAtomValue(countDerivedAtom);
return (
<>
count = {count}
<button onClick={countUp}>set count 2</button>
</>
);
}
export default App; Reproduction Link |
Beta Was this translation helpful? Give feedback.
Answered by
yuneco
Jan 31, 2025
Replies: 1 comment 3 replies
-
Thanks for reporting! I'll look into it. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fixed in #2960 and released in v2.11.2.