How to 'get' another atom's value in atomWithStorage storage-functions? #2684
Answered
by
dai-shi
PhilipGrefe
asked this question in
Q&A
-
Hi, I'm using atomWithStorage with a custom storage implementation. const myAtom = atomWithStorage(
'foo',
'bar',
{
getItem: async (key, initialValue) => {
// const anotherAtom = get(anotherAtom) 🤔
return "baz"
},
//...
) |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Aug 4, 2024
Replies: 1 comment 4 replies
-
It depends on how often Another hack is use Store API, but that technically breaks pure atom model. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If atomFamily works for your case, it might be easier.
atom-in-atom is the way to create an atom which internally creates atomWithStorage.