Function useSignalScope

  • React hook for managing an Alien Signals effect scope. All signals/effects created inside this scope run when the component mounts, and are stopped automatically when the component unmounts.

    Returns EffectScope

    The created effect scope.

    function ScopedEffects() {
    const scope = useSignalScope();
    useEffect(() => {
    scope.run(() => {
    createEffect(() => {
    console.log('Scoped effect:', someSignal.get());
    });
    });
    }, [scope]);
    return null;
    }