Member-only story

React Hooks — A Conceptual Overview

What are React hooks, and why are they important?

Alex Z
3 min readMay 11, 2021
credit: fireship.io — https://www.youtube.com/watch?v=TNhaISOUy6Q&t=367s&ab_channel=Fireship

Before we start talking about React hooks at all, I wanted to first answer the question — what are hooks? As a general concept hooks are interfaces that allow us to ‘hook in’ to an event or component of a system, and allow us to add or modify that systems behavior.

Callbacks are often used to hook into abstracted methods, allowing the author of that method to leave space for the user of the function to customize the execution of it later.

In the example below, we give the function user two different methods that they can use to ‘hook’ into the execution of this method: beforeCallback, which executes after the primary computation is complete, and afterCallback, which… well, you know 😄. In real life situations this might be significantly more complex, but the concept is still fairly similar.

In React, the function that you are hooking into with your hooks is the rendering cycle of a react functional component. A simple one might look like this:

--

--

Alex Z
Alex Z

Written by Alex Z

Software Developer + Product Manager. Interested in Travel, Culture, Economics and the Internet. Join Medium: https://tinycode.medium.com/membership

No responses yet