I am trying to convert my recoil code to jotai. However, i'm having trouble understanding effects for jotai. How do i use recoil in jotai? I know they have jotai-effect but seems like its not working right
My origin recoil code
key: 'user',
default: null,
effects: [storageEffect, userEffect],
});
function storageEffect({setSelf, onSet, resetSelf}) => {
//code
}
function userEffect({setSelf}) => {
//code
}
What i did so far in jotai
const userEffect = atomEffect(() => {
storageEffect
userEffect
});
export const user = atom<any>(get => {
get(firebaseUserEffect);
});
what is the equivalent jotai code for recoil that has effects with setSelf, onSet and resetSelf?
The docs for jotai-effect are inadequate and do not give a full simple example of how to activate an effect when state changes.
This is the recipe I use when I need to run third party code conditional on an atom value (I don't even bother using jotai-effects):