# react-merge-refs-esm

> An esm fork of the React utility to merge refs.

Latest version **1.1.10** (published 2021-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-merge-refs-esm
pnpm add react-merge-refs-esm
yarn add react-merge-refs-esm
bun add react-merge-refs-esm
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.10 |
| Published | 2021-11-07 |
| First published | 2021-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 671 |
| Author | Greg Bergé |
| Maintainers | hunterhcaron |
| Keywords | react, utility, ref |

## Links

- npm: https://www.npmjs.com/package/react-merge-refs-esm
- Repository: https://github.com/gregberge/react-merge-refs
- Funding: https://github.com/sponsors/gregberge
- npm.io page: https://npm.io/package/react-merge-refs-esm

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.10 (latest) — 2021-11-07
- 1.1.9 — 2021-11-07
- 1.1.8 — 2021-11-07
- 1.1.7 — 2021-11-07
- 1.1.6 — 2021-11-07
- 1.1.5 — 2021-11-07
- 1.1.4 — 2021-11-07
- 1.1.3 — 2021-10-31
- 1.1.2 — 2021-10-31
- 1.1.1 — 2021-10-31
- 1.1.0 — 2021-10-31

## README

# react-merge-refs

![Node.js CI](https://github.com/gregberge/react-merge-refs/workflows/Node.js%20CI/badge.svg)

React utility to merge refs 🖇

```sh
npm install react-merge-refs
```

## Example

```js
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

---
_Source: https://npm.io/package/react-merge-refs-esm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
