For those that are transitioning from React Class Components or maybe just want a little more legibility in their code.
npm install @murden.dev/lifecycle-hooks
import { useOnMount, useOnUnmount, useOnUpdate } from '@murden.dev/lifecycle-hooks'
const Component = () => {
useOnMount(() => {
// Function that runs only once, when Component is mounted
})
useOnUnmount(() => {
// Function that runs only once, when Component is about to be unmounted
})
useOnUpdate(() => {
// Function that runs on every Component re-render
})
// (...)
}