UseEffect constructor
UseEffect(
- Function callback,
- List<
ReactterHook> dependencies, [ - ReactterContext? context
Implementation
UseEffect(
this.callback,
this.dependencies, [
this.context,
]) : super(context) {
listenHooks(dependencies);
if (context == null) {
_watchDependencies();
return;
}
if (context is DispatchEffect) {
_runCallbackAndWatchDependencies(null, null);
}
UseEvent.withInstance(context)
..on(Lifecycle.didMount, _runCallbackAndWatchDependencies)
..on(Lifecycle.willUnmount, _runCleanupAndUnwatchDependencies)
..one(Lifecycle.destroyed, (_, __) => dispose());
}