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
It's fine to construct objects that contain atoms or selectors to represent your state. But, what is your error exactly? Are you trying to pass in totals directly to a hook such as useRecoilState()? It is correct that only atoms or selectors should be used for that hook parameter. e.g.
It is generally recommended to use atoms to represent primitives or simple values, as atoms and selectors are the granularity of subscriptions. However, if that isn't a concern and it is laborious to do so, you are free to store richer objects in atoms.
Hi there, just trying to get my head around using Recoil in an application and I've got the following use-case:
const [totals, setTotals] = React.useState<Totals>({ gross: 0, vat: 0, total: 0, savings: 0, });
How would I create this as a Recoil state object? I've tried the following:
Which is causing typescript errors, because totals isn't an atom.
The text was updated successfully, but these errors were encountered: