1.0.0 • Published 4 years ago

@murden.dev/lifecycle-hooks v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

@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
    })

    // (...)
}