Socket
Socket
Sign inDemoInstall

@react-hook/merged-ref

Package Overview
Dependencies
3
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

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


Version published
Maintainers
1
Install size
16.9 kB
Created

Readme

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

FAQs

Last updated on 03 Oct 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc