Who likes React custom Hooks? 
Here are 8 that I found especially helpful or particularly interesting
useInitialMount - returns whether or not the current render is the first
/thread

Here are 8 that I found especially helpful or particularly interesting


/thread



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



There was a proposal for a built-in Hook called `useOpaqueIdentifier` but I'm not sure what happened to it
(uses `useInitialMount`







(uses `useIsMounted`







(uses `useRafState` to debounce




Will need to update react-hooks/exhaustive-deps ESLint rule to validate this Hook too
Less performant so shouldn't use everywhere


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 
https://github.com/streamich/react-use


https://github.com/streamich/react-use


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

(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


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