From the course: React Hooks

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Building a fetch component

Building a fetch component - React.js Tutorial

From the course: React Hooks

Start my 1-month free trial

Building a fetch component

- [Instructor] Now that I have the useFetch hook created, it's time to use it. So let's create an app component again in our, index file. Let's also get rid of the provider and instead just render the app. So inside of this app component, we want to display some data from that API. So, we'll use the same one from before, and we're also going to pass in the login, as a property. So, a couple things we need to do here. Remember our useFetch hook takes in the URI for our API. So it's at api.github.com/users. And then we can chain on this little template here, and say login. So that's whatever the username for the GitHub user is. So you can use your own or whatever you feel like using. Now useFetch returns, an object with loading, data and error. So this is going to handle all of these different states. We also can get rid of create context and use context here on line one. Let's just grab that and get it out of the way.…

Contents