@murden.dev/lifecycle-hooks
v1.0.0
Published
React Class Components lifecycle methods written as React Hooks for those that are transitioning from React Class Components or maybe just want a little more legibility in their code.
Downloads
3
Readme
@murden.dev/lifecycle-hooks
React Class Components lifecycle methods written as React Hooks
For those that are transitioning from React Class Components or maybe just want a little more legibility in their code.
1. Install package
npm install @murden.dev/lifecycle-hooks
2. Import package and enjoy 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
})
// (...)
}