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
) –If present, the effect is only re-run when one of the dependencies has changed. If absent, the effect is only run on initial render.
-
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.