Helper for react effects that only run once
npm install use-onceuseEffect(cbk, []) runs only once and that useEffect(cbk) runs every time.bash
npm install --save use-onceOr
yarn add use-once
`Usage
`js
import {useOnce} from 'use-once'function ReactComp(props) {
useOnce(() => {
console.log('This will only be run once for each instance of the component, instead of after every update.')
return () => {
console.log('Returning a function is optional. The returned function will be called when the component is unmounted.')
}
})
return null
}
``