Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store (atom) composition #3

Open
rankun203 opened this issue Mar 24, 2021 · 0 comments
Open

Store (atom) composition #3

rankun203 opened this issue Mar 24, 2021 · 0 comments

Comments

@rankun203
Copy link
Contributor

rankun203 commented Mar 24, 2021

We are trying to use the same API response (piece of data) in different components. So we are putting API response data & metadata into a store. Basically trying to mimic React Query / SWR

Is there a way to do store composition? For example

const productsResp = atom({
  data: atom([]),
  isLoading: atom(false),
  isError: atom(false),
  isSuccess: atom(true),
});

So we can conditionally render different components with these state and don't have to pass all API loading states around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant