Recoil
Recoil copied to clipboard
Set value to `atomFamily` from `get` method of `selectorFamily`.
import { atomFamily, selectorFamily } from 'recoil';
export const tagState = atomFamily( { ... } )
export const tagListState = selectorFamily( {
key : 'list',
get( options ) {
return async () => {
const list = await getList();
list.forEach( ( item ) => {
// I want to set data here.
set( tagState( item.id ), item );
} );
return list;
};
}
} );
As the code above, I want to store each tag into an atom
after loading them as an array from remote server.
What is the best way for doing this?