You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
723 B
20 lines
723 B
import { DependencyList, EffectCallback } from 'react';
|
|
/**
|
|
* An _immediate_ effect that runs an effect callback when its dependency array
|
|
* changes. This is helpful for updates should must run during render, most
|
|
* commonly state derived from props; a more ergonomic version of https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
|
|
*
|
|
* ```ts
|
|
* function Example({ value }) {
|
|
* const [intermediaryValue, setValue] = useState(value);
|
|
*
|
|
* useUpdateImmediateEffect(() => {
|
|
* setValue(value)
|
|
* }, [value])
|
|
* ```
|
|
*
|
|
* @category effects
|
|
*/
|
|
declare function useUpdateImmediateEffect(effect: EffectCallback, deps: DependencyList): void;
|
|
export default useUpdateImmediateEffect;
|