preact-merge-refs
v1.0.3
Published
Simple utility function for merging Preact refs
Downloads
4,802
Readme
preact-merge-refs
Simple utility function for merging Preact refs.
Installation
npm i preact-merge-refs
Usage
import { useRef } from 'preact/hooks';
import { mergeRefs } from 'preact-merge-refs'
const refFunc = (node) => {};
export const TestComponent() {
const ref1 = useRef();
const ref2 = useRef();
return (
<div ref={mergeRefs([ref1, ref2, refFunc])} />
);
}
API
export declare function mergeRefs<T = any>(
refs: Array<Preact.Ref<T>>
): Preact.RefCallback<T>;