프로젝트
GitHub에서 보기
gregberge/react-merge-refs
소개
refs를 병합하는 React 유틸리티 🖇
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalreact-merge-refs
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
관련 프로젝트 살펴보기
불러오는 중…