facebookexperimental / Recoil

Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.
https://recoiljs.org/
MIT License
19.6k stars 1.19k forks source link

[docs] Add some examples for working with nested state #101

Closed jaredpalmer closed 4 years ago

jaredpalmer commented 4 years ago

Right now, the docs show nearly all atom state to be strings or numbers. It would be great to show how to use atomFamily and selectorFamily to work with nested data and normalized data

davidmccabe commented 4 years ago

Good idea, we're rolling out more docs and examples. Thanks for the feedback.

davidmccabe commented 4 years ago

The short answer is that the contents of atoms is opaque as far as Recoil is concerned, so there's nothing to do.

jaredpalmer commented 4 years ago

I would just show one example. It removes the reader from having to guess.

drarmstr commented 4 years ago

@jaredpalmer - Is something like https://recoiljs.org/docs/guides/asynchronous-data-queries#data-flow-graph what you were thinking?

jaredpalmer commented 4 years ago

@drarmstr I think I figured this out.

https://codesandbox.io/s/recoil-sandbox-20200516-meh12?file=/src/App.js

Note: I'm not data fetching with recoil or with suspense

Kapture 2020-05-18 at 15 03 14