🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@react-hook/merged-ref

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-hook/merged-ref

A React hook for merging multiple refs into one ref

1.3.2
latest
Source
npm
Version published
Weekly downloads
52K
-33.92%
Maintainers
1
Weekly downloads
 
Created
Source

useMergedRef()

Bundlephobia Types Build status NPM Version MIT License

npm i @react-hook/merged-ref

A React hook for merging multiple refs into one ref

Quick Start

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)

function useMergedRef<T>(...refs: React.Ref<T>[]): React.RefCallback<T>
ArgumentDescription
refsReact callback refs or refs created with useRef(), createRef()

Returns React.RefCallback

Returns a callback ref

LICENSE

MIT

Keywords

react

FAQs

Package last updated on 03 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts