Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.51 KB

hook-factory.md

File metadata and controls

38 lines (25 loc) · 1.51 KB

Hook Factory

preact-scoped-model provides a set of functions which produces Preact-based hooks based on the out-of-the-box hooks. These functions accepts the same set of parameters as their hook counterparts.

List of Hook Factories

  • createValue: creates a hook based on useValue.
import { createValue } from 'preact-scoped-model';

const useTimer = createValue(Timer);

// ...
const { seconds } = useTimer();
import { createSelector } from 'preact-scoped-model';

const useTimerSeconds = createSelector(Timer, (state) => state.seconds);

// ...
const seconds = useTimerSeconds();

See Also