Creating Custom React Hooks

For the past several weeks I’ve continued to explore the impact of React Hooks, an upcoming feature that is accessible via version 16.7.0-alpha.2. The two major improvements to React applications I’ve noticed are:

  • More simplicity, including less overall lines of code
  • Less code repetition, enabling adherence to the DRY (don’t repeat yourself) principle
  • Ability to modularize behaviors

Read More

React Context with Hooks

 

Note: React Hooks are still an experimental proposal. This post was written while Hooks were in React 16.7.0-alpha.2

I’ve spent the last several days experimenting the latest React Hooks features. It really has been a blast — so much code deletion when converting from the class stuff. Being a bit newer to React, I haven’t put together any huge applications with the library/framework (I say framework) and so I wasn’t really up to speed with using React Context. I spent a bit of time learning how to use context the classic way, and once I grasped that I decided I’d get a hang of the Hooks’ method: useContext. I wanted to document what I learned along the way by showing a small app I created using it.

 

Wait…What is Context in React?

Read More

Replacing React Classes with Hooks

Note: React Hooks are still an experimental proposal. This post was written while Hooks were in React 16.7.0-alpha.2

Note: Even if Hooks become an official React feature, they aren’t replacing classes, and the React docs don’t recommend huge rewrites replacing classes with Hooks.

I’m at the point in learning React where I’ve written some apps that use both class components and functional components. Admittedly, I should probably be focusing on using React’s core functionalities to develop larger apps before I start delving into its unreleased/experimental stuff, but I could not resist! After watching some talks from React Conf 2018, I decided to rewrite some of my current code using React Hooks. I wanted to write a post walking through a bit of my experience with it.

Read More