Package Exports
- react-life-hooks
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-life-hooks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-life-hooks
React hooks for better managing lifecycles for function component.
This lib want keep as helpers
, but not targeting a fully Custom Hooks.
Install
You can install from NPM, or use files in lib
.
npm install --save react-life-hooks
Usage
This lib require React 16.8.0 or later, since it's based on React Hooks API.
Each helper can be imported individually:
import {
onInit,
onDidMount,
onDidUpdate,
onDidRender,
onDidUpdate,
useLifeState,
useLifeReducer,
createUpdate,
createRef,
onChange,
onWillUnmount
} from 'react-life-hooks';
function createRef(create=>Hello(){
onDidMount(()=>{
console.log('component did mount!');
});
onWillUnmount(()=>{
console.log('component will unmount!');
});
return <div>Hello</div>
});