Skip to content
Proyek

gregberge/react-merge-refs

Lihat di GitHub

Tentang

Utilitas React untuk menggabungkan ref ๐Ÿ–‡

Pengembangan web dan aplikasi

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
+1
dalam 15 hari
+1
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

react-merge-refs

License npm package npm bundle size CI

React utility to merge refs ๐Ÿ–‡

npm install react-merge-refs

Example

import React from "react";
import { mergeRefs } from "react-merge-refs";

const Example = React.forwardRef(function Example(props, ref) {
  const localRef = React.useRef();
  return <div ref={mergeRefs([localRef, ref])} />;
});

Why?

When developing low level UI components, it is common to have to use a local ref but also support an external one using React.forwardRef. Natively, React does not offer a way to set two refs inside the ref property. This is the goal of this small utility.

Today a ref can be a function or an object, tomorrow it could be another thing, who knows. This utility handles compatibility for you.

License

MIT

Jelajahi proyek terkait

Memuatโ€ฆ