preact-merge-refs
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

preact-merge-refs

npm

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>;

Readme

Keywords

Package Sidebar

Install

npm i preact-merge-refs

Weekly Downloads

1,255

Version

1.0.3

License

UNLICENSED

Unpacked Size

3.4 kB

Total Files

7

Last publish

Collaborators

  • fakundo