Ref composition helpers for Fict, modeled after @radix-ui/react-compose-refs. Combine several refs (callback refs or ref objects) into a single ref callback.
Part of ui-primitives, a port of Radix Primitives to Fict.
pnpm add @fictjs/compose-refsimport { composeRefs } from '@fictjs/compose-refs'
function Field(props) {
const localRef = { current: null }
// Assign the combined callback to an element's ref; every provided ref receives the node.
const setRef = composeRefs(localRef, props.ref)
return <input ref={setRef} />
}composeRefs(...refs)— returns a callback that assigns the node to every provided ref.useComposedRefs(...refs)— the same, intended for use inside components.
Both accept callback refs and { current } ref objects, and safely ignore null/undefined.
- Values:
composeRefs,useComposedRefs. - Types:
PossibleRef.
The API mirrors @radix-ui/react-compose-refs. See the ui-primitives overview and the architecture guide.
MIT © Fict contributors.