yummies/react
Description
React helpers shipped as optional peer dependency: stable event callbacks (useEvent), refs, observers (intersection, resize), abort signals, and attachRefs for forwarding to multiple refs. Hooks follow patterns from RFCs and day-to-day UI needs without pulling a second hook library. Import names directly from yummies/react; tree-shaking keeps unused hooks out of the bundle.
Usage
import { useToggle, attachRefs } from "yummies/react";InstanceCreateConfig
No description.
createUseInstanceHook()
Builds a custom hook that creates an instance once and wires lifecycle helpers such as an AbortSignal and optional extension data into the factory.
Examples:
const useStoreInstance = createUseInstanceHook({ api });const useService = createUseInstanceHook({ logger });
const service = useService(({ logger, payload }) => new Service(logger, payload));useInstance
The useInstance hook is used to create and manage an instance of an object that requires access to the root store and an abort signal.
You can create YOUR OWN CUSTOM useInstance hook using createUseInstanceHook if you need to provide some specific data
Examples:
const service = useInstance(({ abortSignal }) => new UsersService({ abortSignal }));const store = useInstance(
({ payload }) => new UserStore(payload),
{ payload: userId, onUpdate: (nextId) => console.log(nextId) },
);