# @react-hook/merged-ref

> A React hook for merging multiple refs into one ref

Latest version **1.3.2** (published 2021-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @react-hook/merged-ref
pnpm add @react-hook/merged-ref
yarn add @react-hook/merged-ref
bun add @react-hook/merged-ref
```

## 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.3.2 |
| Published | 2021-10-03 |
| First published | 2019-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1530 |
| Author | Jared Lunde |
| Maintainers | jaredlunde |
| Keywords | react, react hook, merged ref, merge two refs, combine refs, multiple refs, merge refs, merge react refs, usemergerefs, use merge refs, usemergedref, use merged ref |

## Links

- npm: https://www.npmjs.com/package/@react-hook/merged-ref
- Repository: https://github.com/jaredLunde/react-hook
- Homepage: https://github.com/jaredLunde/react-hook/tree/master/packages/merged-ref#readme
- Issues: https://github.com/jaredLunde/react-hook/issues
- npm.io page: https://npm.io/package/@react-hook/merged-ref

## 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.3.2 (latest) — 2021-10-03
- 1.3.1 — 2021-10-03
- 1.3.0 — 2020-06-07
- 1.2.1 — 2020-06-04
- 1.2.0 — 2020-05-31
- 1.1.1 — 2020-02-12
- 1.1.0 — 2020-02-11
- 1.0.8 — 2019-12-25
- 1.0.7 — 2019-12-13
- 1.0.6 — 2019-12-09
- 1.0.5 — 2019-12-09
- 1.0.4 — 2019-11-25
- 1.0.3 — 2019-11-25
- 1.0.2 — 2019-09-18
- 1.0.1 — 2019-09-18
- … 1 more at https://npm.io/package/@react-hook/merged-ref/versions

## README

<hr>
<div align="center">
  <h1 align="center">
    useMergedRef()
  </h1>
</div>

<p align="center">
  <a href="https://bundlephobia.com/result?p=@react-hook/merged-ref">
    <img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/@react-hook/merged-ref?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="Types" href="https://www.npmjs.com/package/@react-hook/merged-ref">
    <img alt="Types" src="https://img.shields.io/npm/types/@react-hook/merged-ref?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="Build status" href="https://travis-ci.com/jaredLunde/react-hook">
    <img alt="Build status" src="https://img.shields.io/travis/com/jaredLunde/react-hook?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="NPM version" href="https://www.npmjs.com/package/@react-hook/merged-ref">
    <img alt="NPM Version" src="https://img.shields.io/npm/v/@react-hook/merged-ref?style=for-the-badge&labelColor=24292e">
  </a>
  <a aria-label="License" href="https://jaredlunde.mit-license.org/">
    <img alt="MIT License" src="https://img.shields.io/npm/l/@react-hook/merged-ref?style=for-the-badge&labelColor=24292e">
  </a>
</p>

<pre align="center">npm i @react-hook/merged-ref</pre>
<hr>

A React hook for merging multiple refs into one ref

## Quick Start

```jsx harmony
import React from 'react'
import useMergedRef from '@react-hook/merged-ref'

const Component = React.forwardRef((props, ref) => {
  const otherRef = React.useRef(null)
  const multiRef = useMergedRef(ref, otherRef)
  return <div ref={multiRef} />
})
```

## API

### `useMergedRef(...refs)`

```ts
function useMergedRef<T>(...refs: React.Ref<T>[]): React.RefCallback<T>
```

| Argument | Description                                                        |
| -------- | ------------------------------------------------------------------ |
| refs     | React callback refs or refs created with `useRef()`, `createRef()` |

#### Returns `React.RefCallback`

Returns a callback ref

## LICENSE

MIT

---
_Source: https://npm.io/package/@react-hook/merged-ref · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
