UNPKG

solid-awesome-hooks

Version:
10 lines (9 loc) 524 B
import { createComputed, on } from "solid-js"; /** * This hook may be used to sync your state (signals or stores) with props. * Basically it's just a shorthand for createComputed(on(source, setter, { defer })) * @param source Reactive signal * @param setter A function which runs immediately when source changes * @param defer A boolean value which is passed to on's defer option. Default - true. */ export const useSyncState = (source, setter, defer = true) => createComputed(on(source, setter, { defer }));