Skip to content

A package for those that are transitioning from React Class Components or maybe just want a little more legibility in their code.

Notifications You must be signed in to change notification settings

matheusmurden/use-lifecycle-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

    // (...)
}

About

A package for those that are transitioning from React Class Components or maybe just want a little more legibility in their code.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published