Appearance
useEffectOnce
useEffect 的快捷方式,只在 onMount 和 onBeforeUnmount 阶段执行的 Hook。
Demo
</>
Please open console
Usage
import { useEffectOnce } from 'v3-use'
useEffectOnce(() => {
console.log('mounted 执行')
return () => {
console.log('beforeUnmount 执行')
}
})
import { useEffectOnce } from 'v3-use'
useEffectOnce(() => {
console.log('mounted 执行')
return () => {
console.log('beforeUnmount 执行')
}
})
Reference
Type Declarations
export declare function useEffectOnce(effect: EffectCallback): void
export declare function useEffectOnce(effect: EffectCallback): void