You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to https://recoiljs.org/docs/api-reference/utils/atomFamily/#parameter-type it is possible to provide a function as default to an atomFamily like this: const myAtomFamily = atomFamily({ key: ‘MyAtom’, default: param => defaultBasedOnParam(param), });
If I want to fetch a specific atom from the family (or create a new one if it doesn't exist) I can do so like this: useRecoilState(myAtomFamily(myId));
How can I do the above and provide the param to the default function? From the documentation, this is not clear. (I also tried various combinations and was not successful)
I expected something like this but it just errors out: useRecoilState(myAtomFamily(myId, myValueToTheDefaultFunction));
I'm happy to create a PR for updating the documentation if I get a working example.
The text was updated successfully, but these errors were encountered:
According to https://recoiljs.org/docs/api-reference/utils/atomFamily/#parameter-type it is possible to provide a function as default to an atomFamily like this:
const myAtomFamily = atomFamily({ key: ‘MyAtom’, default: param => defaultBasedOnParam(param), });
If I want to fetch a specific atom from the family (or create a new one if it doesn't exist) I can do so like this:
useRecoilState(myAtomFamily(myId));
How can I do the above and provide the param to the default function? From the documentation, this is not clear. (I also tried various combinations and was not successful)
I expected something like this but it just errors out:
useRecoilState(myAtomFamily(myId, myValueToTheDefaultFunction));
I'm happy to create a PR for updating the documentation if I get a working example.
The text was updated successfully, but these errors were encountered: