Who likes React custom Hooks? ![Erhobene Hand (durchschnittlich dunkler Hautton) ✋🏾](https://abs.twimg.com/emoji/v2/72x72/270b-1f3fe.png)
Here are 8 that I found especially helpful or particularly interesting![Nerd-Gesicht 🤓](https://abs.twimg.com/emoji/v2/72x72/1f913.png)
useInitialMount - returns whether or not the current render is the first
/thread![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Erhobene Hand (durchschnittlich dunkler Hautton) ✋🏾](https://abs.twimg.com/emoji/v2/72x72/270b-1f3fe.png)
Here are 8 that I found especially helpful or particularly interesting
![Nerd-Gesicht 🤓](https://abs.twimg.com/emoji/v2/72x72/1f913.png)
![Tastenkappe Ziffer 1 1️⃣](https://abs.twimg.com/emoji/v2/72x72/31-20e3.png)
/thread
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
![Tastenkappe Ziffer 2 2️⃣](https://abs.twimg.com/emoji/v2/72x72/32-20e3.png)
So common it's in the React Hooks FAQ but that one has a potential gotcha where prev value can get overwritten when comp re-renders for other reasons
This only updates prev value if it differs from new val
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
![Tastenkappe Ziffer 3 3️⃣](https://abs.twimg.com/emoji/v2/72x72/33-20e3.png)
There was a proposal for a built-in Hook called `useOpaqueIdentifier` but I'm not sure what happened to it
(uses `useInitialMount`
![Zwinkerndes Gesicht 😉](https://abs.twimg.com/emoji/v2/72x72/1f609.png)
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
![Tastenkappe Ziffer 4 4️⃣](https://abs.twimg.com/emoji/v2/72x72/34-20e3.png)
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
![Tastenkappe Ziffer 5 5️⃣](https://abs.twimg.com/emoji/v2/72x72/35-20e3.png)
(uses `useIsMounted`
![Zwinkerndes Gesicht 😉](https://abs.twimg.com/emoji/v2/72x72/1f609.png)
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
![Tastenkappe Ziffer 6 6️⃣](https://abs.twimg.com/emoji/v2/72x72/36-20e3.png)
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
![Tastenkappe Ziffer 7 7️⃣](https://abs.twimg.com/emoji/v2/72x72/37-20e3.png)
(uses `useRafState` to debounce
![Zwinkerndes Gesicht 😉](https://abs.twimg.com/emoji/v2/72x72/1f609.png)
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
![Tastenkappe Ziffer 8 8️⃣](https://abs.twimg.com/emoji/v2/72x72/38-20e3.png)
Will need to update react-hooks/exhaustive-deps ESLint rule to validate this Hook too
Less performant so shouldn't use everywhere
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
Flavors of most of these React custom Hooks can be found in the `react-use` package. It has tons more too that you should definitely check out ![Thumbs up (durchschnittlich dunkler Hautton) 👍🏾](https://abs.twimg.com/emoji/v2/72x72/1f44d-1f3fe.png)
https://github.com/streamich/react-use
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Thumbs up (durchschnittlich dunkler Hautton) 👍🏾](https://abs.twimg.com/emoji/v2/72x72/1f44d-1f3fe.png)
https://github.com/streamich/react-use
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
I already put together all 8 of these custom Hooks w/ implementations, code comments & use cases in my latest post
(no need to unroll the thread
)
What custom Hooks do you find yourself using a lot?
https://www.benmvp.com/blog/8-helpful-custom-react-hooks/?utm_source=twitter&utm_medium=social&utm_campaign=init-share
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
(no need to unroll the thread
![Gesicht mit Freudentränen 😂](https://abs.twimg.com/emoji/v2/72x72/1f602.png)
What custom Hooks do you find yourself using a lot?
https://www.benmvp.com/blog/8-helpful-custom-react-hooks/?utm_source=twitter&utm_medium=social&utm_campaign=init-share
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
![Rückhand Zeigefinger nach unten (durchschnittlich dunkler Hautton) 👇🏾](https://abs.twimg.com/emoji/v2/72x72/1f447-1f3fe.png)
Aaaaaand if you like these types of explanatory posts, make sure you subscribe to the MVP Newsletter. I jump around between React, JavaScript, TypeScript, DivOps & other frontend-related topics https://www.benmvp.com/subscribe/?utm_source=twitter&utm_medium=social&utm_campaign=8-helpful-custom-react-hooks