React Hooks

September 08, 2019

It's been a while since my last blog post.

I have some stuff to share about React, particularly hooks.

I've heard of Hooks for a long time, probably two months ago. (I just started studying react four months ago). I just finished studying redux and decided to study hooks after writing this blog post.

After reading the introduction from the hooks doc, I watched this video that helped me get started with hooks. I've seen a few examples of using react hooks and decided to try it on my own.

I made a simple react app that fetches 100 posts using the JSON Placeholder API

Screenshots below are my source codes using a class component -- use of render method and this.

And a functional component -- use of hooks.

Class Component

class component

Functional Component

functional component

What can I say?

Using hooks look cleaner and readable than that ol' pesky this render method class components stuff. I'm beginning to fall in love with Hooks 😍

I mean, the screenshots above are still readable because the app is too simple. But when it comes to flexibility, using hooks may seem like a better choice when developing large-scale projects.

So, should I ditch class components and embrace functional components? Probably soon

I've got a lot of things to learn!

Should I study apollo to ditch redux as well? 🤔

Last modified: 17 days ago
Profile picture

Aethan Matthew