This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
Consider adding prevState to Selector get method. #1675
terminalqo
started this conversation in
Ideas
Replies: 2 comments
-
May be alternative ? atom({
key: "",
default: {
market: "",
group: "",
inst: "",
},
effects: [
({ onSet }) => {
onSet((newVal, oldVal) => {
// Not call in first, but will call in subsequent state change.
console.log("[ newVal, oldVal ] >", newVal, oldVal);
});
},
],
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Selector evaluation functions should be "idempotent", meaning they should always return the same output for a given set of inputs without side-effects (exceptions for caching and such). So, the concept of "previous state" isn't really meaningful for a selector evaluation. |
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
-
I'm using Next.js, However , I get initData from ssr, so I adding initData like this:
And I'm using
selector
to observe some atom state:How can I get
prevState
to prevent unnecessary fetch ?Thank you for help!
Beta Was this translation helpful? Give feedback.
All reactions