Skip to content
public-library›Rules›React›Read the latest callbacks in Effects without resubscribing

Read the latest callbacks in Effects without resubscribing

When an Effect should re-run only for some values but also needs the latest version of others, such as a callback prop, read those others through useEffectEvent, or through a ref in React versions without it. Keep only the values that should restart the Effect in its dependency array.

In the full rule