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

Add support for Hooks #25

Open
3 tasks
techniq opened this issue Dec 6, 2018 · 1 comment
Open
3 tasks

Add support for Hooks #25

techniq opened this issue Dec 6, 2018 · 1 comment

Comments

@techniq
Copy link
Owner

techniq commented Dec 6, 2018

Support useFetch hooks API

function Example(props) {
  const { loading, data, error } = useFetch({ url: props.url });
  // ...
}

along with the existing Fetch render props component

function Example(props) {
  <Fetch url={props.url}>
    {({ loading, data, error }) => (
      // ...
    )}
  </Fetch>
}

To support consistency with the Fetch component, the useFetch hook will take in a props object for url, options, etc.

I might consider change the name of the package to better represent it's not just a component (but also a hook). I'm considering using a scoped @techniq/react-fetch instead of trying to come up with a unique name.

TODO

  • Update README
  • Switch to Typescript
  • Wait for official React release with hooks
@techniq
Copy link
Owner Author

techniq commented Dec 6, 2018

Released as npm install react-fetch-component@next (pre-release 8.0.0-0).

Package name may change before becoming official (and won't be official until Hooks are official / non-alpha)

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

No branches or pull requests

1 participant