@zitterorg/delectus-est
v5.2.64
Published
[![npm](https://img.shields.io/npm/v/@zitterorg/delectus-est.svg)](https://www.npmjs.com/package/@zitterorg/delectus-est) ![downloads](https://img.shields.io/npm/dt/@zitterorg/delectus-est.svg) [![CI](https://github.com/zitterorg/delectus-est/actions/work
Downloads
66
Maintainers
Keywords
Readme
Merge-Refs
A function that merges React refs into one. Filters out invalid (eg. falsy) refs as well and returns original ref if only one valid ref was given.
tl;dr
- Install by executing
npm install @zitterorg/delectus-est
oryarn add @zitterorg/delectus-est
. - Import by adding
import mergeRefs from '@zitterorg/delectus-est'
. - Use it in
ref
like so:<div ref={mergeRefs(ref, someOtherRef)} />
Accepted refs
- Refs created using
createRef()
- Refs created using
useRef()
- Functional refs
Example
function Hello() {
const ref1 = useRef<HTMLDivElement>(); // I'm going to be updated!
const ref2 = (element: HTMLDivElement) => {
// I'm going to be called!
};
return <div ref={mergeRefs(ref1, ref2)} />;
}
License
The MIT License.