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

Support React Suspense #6

Open
zxqx opened this issue Aug 12, 2019 · 6 comments
Open

Support React Suspense #6

zxqx opened this issue Aug 12, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@zxqx
Copy link
Member

zxqx commented Aug 12, 2019

No description provided.

@jpangelle
Copy link
Member

Haven’t worked with suspense yet. Will have to look into it.

@zxqx
Copy link
Member Author

zxqx commented Aug 14, 2019

I've been messing with it the last few nights - I'll throw up a PR soon with some Suspense stuff.

@jpangelle
Copy link
Member

Hell ya

@zxqx
Copy link
Member Author

zxqx commented Aug 14, 2019

So this is the API I'm toying with (and an example implementation):

const Example = () => {
  const { data, error } = useFetch('https://example.com', { suspense: true });

  if (error) {
    return <div>{error}</div>;
  }

  return <div>{data}</div>;
};

const App = () => (
  <React.Suspense fallback={'Loading...'}>
    <Example />
  </React.Suspense>
);

We could also just make separate hooks, but my thought is that it may be better to have it as an option on each hook, otherwise we'd have to make a corresponding suspense-ready hook for each regular hook (e.g. useSuspenseFetch, useSuspenseLazyFetch).

Thoughts?

cc: @bvalosek

@jpangelle
Copy link
Member

Damn, that’s pretty sick. Def wanna explore that

@zxqx zxqx self-assigned this Aug 18, 2019
@zxqx
Copy link
Member Author

zxqx commented Aug 19, 2019

Will leave this issue open for now - let's use this to drop any relevant thoughts and implementation ideas as data fetching with Suspense matures.

@zxqx zxqx changed the title Update hooks to work with React Suspense Support React Suspense Oct 8, 2019
@zxqx zxqx added the enhancement New feature or request label Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants