use_effect
use_effect
#
use_effect(
setup: Callable[[], Any | Awaitable[Any]],
dependencies: Sequence[Any] | None = None,
cleanup: Callable[[], Any | Awaitable[Any]]
| None = None,
)
Perform side effects in function components.
PARAMETER | DESCRIPTION |
---|---|
setup
|
A function that performs the side effect. It may optionally return a cleanup function. |
dependencies
|
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
|
An optional function that cleans up after the effect. It is run before the effect is re-run, and when the component unmounts.
TYPE:
|