mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
chore: use unsafe effect
This commit is contained in:
13
packages/lib/client-only/hooks/use-effect-once.ts
Normal file
13
packages/lib/client-only/hooks/use-effect-once.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import type { EffectCallback } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
/**
|
||||
* Dangerously runs an effect "once" by ignoring the depedencies of a given effect.
|
||||
*
|
||||
* DANGER: The effect will run twice in concurrent react and development environments.
|
||||
*/
|
||||
export const unsafe_useEffectOnce = (callback: EffectCallback) => {
|
||||
// Intentionally avoiding exhaustive deps and rule of hooks here
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/rules-of-hooks
|
||||
return useEffect(callback, []);
|
||||
};
|
||||
Reference in New Issue
Block a user