Better Programming

Advice for programmers.

Follow publication

Member-only story

How To Fetch Data From an API With React Hooks

Functional data fetching

Trevor-Indrek Lasn
Better Programming
Published in
4 min readJun 21, 2019

React Hooks let us write pure functional components without ever using the class syntax. Usually, but not always, the less code we have to write, the faster we’re building our application.

If you’re new to Hooks, check out this tutorial for a Hooks introduction.

Feel free to become a Medium member by using my referral link. Your membership fee directly supports me and other writers you read. You’ll also get full access to every story on Medium

Step 1. Refactoring From a Class to Functional Component

Take this plain React class-based component. Our first step to using Hooks would be to refactor it to a functional component. Remember, you use Hooks only with functional components.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (13)

Write a response