October 2019
Intermediate to advanced
426 pages
11h 49m
English
The useLifecycleHooks Hook combines the previous two Hooks into one. We can combine the useOnMount and useOnUnmount Hooks as follows:
import React from 'react'import { useLifecycleHooks } from 'react-hookedup'export default function UseLifecycleHooks () { useLifecycleHooks({ onMount: () => console.log('lifecycle mounted'), onUnmount: () => console.log('lifecycle unmounting') }) return <div>look at the console and click the button</div>}
Alternatively, we could use the two Hooks separately:
import React from 'react'import { useOnMount, useOnUnmount } from 'react-hookedup'export default function UseLifecycleHooksSeparate () { useOnMount(() => console.log('separate lifecycle mounted')) useOnUnmount(() => console.log('separate ...Read now
Unlock full access