JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 37861
  • Score
    100M100P100Q153840F
  • License MIT

A React hook for merging multiple refs into one ref

Package Exports

  • @react-hook/merged-ref

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@react-hook/merged-ref) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme


useMergedRef()

Bundlephobia Types 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: ReactRef[]): CallbackRef

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

Returns ref: CallbackRef

Returns a callback ref

LICENSE

MIT