diff --git a/.changeset/mean-flies-grow.md b/.changeset/mean-flies-grow.md new file mode 100644 index 000000000..cef2089fd --- /dev/null +++ b/.changeset/mean-flies-grow.md @@ -0,0 +1,5 @@ +--- +"@preact/signals": patch +--- + +Made useSignalEffect more permissive in the functions it accepts. diff --git a/packages/preact/src/index.ts b/packages/preact/src/index.ts index caf2c525a..1f2efa00c 100644 --- a/packages/preact/src/index.ts +++ b/packages/preact/src/index.ts @@ -40,7 +40,7 @@ function hook(hookName: T, hookFn: HookFn) { } let currentComponent: AugmentedComponent | undefined; -let finishUpdate: (() => void) | undefined; +let finishUpdate: (() => unknown) | undefined; function setCurrentUpdater(updater?: Effect) { // end tracking for the current update: @@ -49,7 +49,7 @@ function setCurrentUpdater(updater?: Effect) { finishUpdate = updater && updater._start(); } -function createUpdater(update: () => void) { +function createUpdater(update: () => unknown) { let updater!: Effect; effect(function (this: Effect) { updater = this; @@ -356,12 +356,12 @@ export function useComputed(compute: () => T) { return useMemo(() => computed(() => $compute.current()), []); } -export function useSignalEffect(cb: () => void | (() => void)) { +export function useSignalEffect(cb: () => unknown | (() => unknown)) { const callback = useRef(cb); callback.current = cb; useEffect(() => { - return effect(() => callback.current()); + return effect(() => { callback.current() }); }, []); }