2.1.1 • Published 7 months ago

react-merge-refs v2.1.1

Weekly downloads
117,352
License
MIT
Repository
github
Last release
7 months ago

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

@xdn/react@triplex/scene@transferwise/components@design-systems/utils@davezeg/react-three-fiberalphakit-uipylot-framework@sana-ru/provider-search-render@ismael01866/react-playgroundvibo-uiw3r-modal@macaron-app/renderthreeddd-editor@infinitebrahmanuniverse/nolb-react-me@product360/editor@saaspe/components@knapsack/tobyfile-code-link@everything-registry/sub-chunk-2567prpxr3f-framerrms-reactsh-ui-kit-kek@srinivasprabhu/drei@statflo/ui@slate-extensions/slate-autocomplete@skeetboothppq/component-library@smooth-ui/core-em@smooth-ui/core-screact-95-fiberreact-antd-utilsreact-postprocessingrakamin-component-testreact-lightning-design-systemreact-lazy-modal-sheetreact-legato-dndreact-mutable-refsreact-modal-sheet-cusreact-native-jolt-physicspretty-checkbox-reactreact-flavorreact-form-component-libraryreact-balancedreact-circular-gaugereact-directory-inputreact-vtreereact-vtree-griddexreact-vtree-jhreact-window-timelinereact-autowidth-inputreact-canvas-pattern-lockreact-squirclizereact-shopify-drop-testreact-trinityreact-three-fiber-cambrianreact-three-fiber-zegreact-three-drei-without-subdivisionreact-three-editablereact-three-editable-without-subdivisionreact-svg-fxshadergradientshadergradient-oldshadergradient-v2shadermakersourceblocks-g@senja24/cleek-ui@sheetxl/common-react@wonderflow/charts@wonderflow/react-componentsthree-shadermaker@ygorconfig/reactthree-vfx@youyouzone/react-sdftest-rpackage-box-inputtest-rpackage-boxtest-rpackage-box-button@wise/design-system@wise/design-system-tailwindcss@threedddplus/editorreplica-playersedrino-devtools@spacegod12/react-three-fiber@spacegod12/react-three-fiber-2.0@spacegod12/react-three-fiber-3.0@techytools/ui@splinetool/react-spline@sorenhoyer/react-tabs@theatre/plugin-r3f@tossteam/react-three-fiber@xrpl/ai-react@wp-g2/utils@xlnt/paint@storybook/components-marketing@swittk/fiber@moreapp/storybookeddevdxkb-design-systemdxh-dxkb-design-systemdreidrei-patch
2.1.1

7 months ago

2.1.0

7 months ago

2.0.2

12 months ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

4 years ago

1.0.0

5 years ago