@fictjs/use-effect-event
v0.3.4
Published
Stable event callback wrapper for Fict UI primitives.
Maintainers
Readme
@fictjs/use-effect-event
Stable event callback wrapper for Fict, modeled after @radix-ui/react-use-effect-event (React's useEffectEvent). Returns a function with a stable identity that always calls the latest callback — useful for event handlers referenced from effects.
Part of ui-primitives, a port of Radix Primitives to Fict.
Installation
pnpm add @fictjs/use-effect-event fictUsage
import { prop } from 'fict'
import { useEffectEvent } from '@fictjs/use-effect-event'
const onChange = useEffectEvent<(value: string) => void>(prop(() => props.onChange))
// `onChange` never changes identity, but always invokes the current props.onChangeAPI
useEffectEvent(callback)— returns a stable function that forwards tocallback. A direct callback is retained as provided; when a parent can replace it, pass a Fict signal, computed value, orprop(() => callback)so each invocation reads the current callback. An undefined current callback is a no-op.
Exports
- Values:
useEffectEvent.
Documentation
The API mirrors @radix-ui/react-use-effect-event. See the ui-primitives overview and the architecture guide.
License
MIT © Fict contributors.
