use_effect
API
counterweight.hooks.use_effect
PARAMETER | DESCRIPTION |
---|---|
setup |
The setup function that will be called when the component first mounts or if its dependencies have changed (see below).
TYPE:
|
deps |
The dependencies of the effect.
If any of the dependencies change, the previous invocation of the
TYPE:
|
Effect Cancellation
Effects are cancelled by the framework when one of the following conditions is met:
- The component that created the effect is unmounted.
- The effect's dependencies change and the effect's
setup
function is going to be re-run.
Effect cancellation is synchronous
Note that the effect is synchronously cancelled
(i.e., the Task
that represents the effect is cancelled and then await
ed;
see this discussion)
before the next render cycle starts.
Assuming that you do not mess with the cancellation yourself from inside the effect setup function,
the effect will definitely stop running before the next frame is rendered.