Skip to main content

use_effect

Perform side effects in function components.

Parameters:

  • setup (Callable[[], Any | Awaitable[Any]]) - A function that performs the side effect. It may optionally return a cleanup function.
  • dependencies (Sequence[Any] | None, default: None) - Values the effect depends on. The effect always runs after the component mounts. If absent, it also re-runs after every render. If empty, it runs only on mount. Otherwise, it re-runs only when one of the dependencies has changed.
  • cleanup (Callable[[], Any | Awaitable[Any]] | None, default: None) - An optional function that cleans up after the effect. It is run before the effect is re-run, and when the component unmounts.