1 | import { DependencyList, EffectCallback } from 'react';
|
2 | /**
|
3 | * An _immediate_ effect that runs an effect callback when its dependency array
|
4 | * changes. This is helpful for updates should must run during render, most
|
5 | * commonly state derived from props; a more ergonomic version of https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
|
6 | *
|
7 | * ```ts
|
8 | * function Example({ value }) {
|
9 | * const [intermediaryValue, setValue] = useState(value);
|
10 | *
|
11 | * useUpdateImmediateEffect(() => {
|
12 | * setValue(value)
|
13 | * }, [value])
|
14 | * ```
|
15 | *
|
16 | * @category effects
|
17 | */
|
18 | declare function useUpdateImmediateEffect(effect: EffectCallback, deps: DependencyList): void;
|
19 | export default useUpdateImmediateEffect;
|