feat(common): add useMountEffect hook

This commit is contained in:
anthony lio committed 2026-10-02 11:44:03 +03:00
1 parent 6143441493
commit f724a981a8
2 files changed
+13

No files matched your search

+1
View File
@@ -11,6 +11,7 @@ export * from './useDocsSearchV2'
export * from './useDragToClose'
export * from './useEffectEvent'
export * from './useIsomorphicLayoutEffect'
export * from './useMountEffect'
export * from './useOnChange'
export * from './useParams'
export * from './useSearchParamsShallow'
+12
View File
@@ -0,0 +1,12 @@
'use client'
import { useEffect, type EffectCallback } from 'react'
/**
* runs an effect once on mount, with its cleanup on unmount, the escape hatch for one-time
* sync with an external system and derive state or use event handlers everywhere else
*/
export function useMountEffect(effect: EffectCallback): void {
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(effect, [])
}