-
Notifications
You must be signed in to change notification settings - Fork 0
useOnMount
Александр edited this page Jan 17, 2023
·
1 revision
export function useOnMount(callback: () => void): void
Accepts a function without arguments.
Calls it when the component was mounted.
The same as React.useEffect(callback, [])
import { afc, useOnMount } from 'react-afc'
function Component(props) {
useOnMount(() => {
document.addEventListener(/*...*/)
})
return () => (/*...*/)
}
export default afc(Component)
Component
Lifecycle
State
Redux
Other