4 Custom React Hooks Every Developer Should Know

4 Custom React Hooks to Improve Your Efficiency

3 min readApr 17


Photo by Lautaro Andreani on Unsplash

My friends, if I had learned these 4 React hooks earlier, maybe I could have written more beautiful code.

They greatly improved my work efficiency and the scalability and readability of my code. You must want to learn them too?

1. useMount

In the past, I often wrote this style of code, and when the component was first rendered, I needed to send a request or do some other logic, probably like this.

That’s pretty simple, isn’t it? But it has one big disadvantage: The semantics are not clear enough, even if we pass in an empty array.

So we can customize a hook called useMount to execute the callback function only when the component is first rendered.

Source code


When the component re-renders, useMount does not execute again, great!

2. useUnmount




Hi friends, I am a front-end engineer from Alibaba, let’s code happily together.