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
Sometimes we have one state and its value will be changed if and only if another state is changed. Nowadays we have to update their states manually in actions, for instance:
constdefaultFunc=()=>{}{state: {num: 3,sqauredNum: ({ num })=>num*num// calculated statefunc: defaultFunc// function handler}}...constApp=()=>{const[{ sqauredNum }]=useStore('xxx')// use sqauredNum}
The text was updated successfully, but these errors were encountered:
// case 1exportconstA={state: {a: 1,c: ({ a, b })=>a+b,b: ({ a })=>a+1}}// a = 1// assert(b === 2)// assert(c === 3)// case 2exportconstB={state: {a: 1,b: ({ c })=>c+1,c: ({ b })=>b+1}}// a = 1// throw Error('circular dependency in calculated state')
Sometimes we have one state and its value will be changed if and only if another state is changed. Nowadays we have to update their states manually in actions, for instance:
Is there a way to manage only core states and make the derived states (like
sqauredNum
) be re-calculated automatically (like Selectors in https://recoiljs.org/docs/introduction/core-concepts)The text was updated successfully, but these errors were encountered: