mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
feat(common): add useMountEffect hook
This commit is contained in:
1 parent
6143441493
commit
f724a981a8
2 files changed
+13
No files matched your search
@@ -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'
|
||||
|
||||
@@ -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, [])
|
||||
}
|
||||
Reference in new issue
Block a user