useForkRef
Merges refs into a single memoized callback ref or
null.Installation
npx sse-tool add use-fork-ref
npm install sse-hooks
Usage
import { useForkRef } from "./{hooks file}";
const rootRef = React.useRef<Instance>(null);
const refFork = useForkRef(rootRef, props.ref);
return <Root {...props} ref={refFork} />;
import { useForkRef } from "sse-hooks";
const rootRef = React.useRef<Instance>(null);
const refFork = useForkRef(rootRef, props.ref);
return <Root {...props} ref={refFork} />;
API
Parameters
| Name | Type | Description |
| :--- | :--- | :----------- | -------------- |
| refs | Ref | undefined[] | The ref array. |
Return Value
Returns Function | any.
The new ref callback.