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

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

/preact-merge-refs/

    Package Sidebar

    Install

    npm i preact-merge-refs

    Weekly Downloads

    308

    Version

    1.0.2

    License

    UNLICENSED

    Unpacked Size

    3.4 kB

    Total Files

    7

    Last publish

    Collaborators

    • fakundo