Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

dist/cjs/index.d.ts

9

dist/cjs/index.js

@@ -11,3 +11,3 @@ 'use strict'

ref(value)
} else if (ref !== null) {
} else if (ref !== null && typeof ref === 'object') {
ref.current = value

@@ -17,4 +17,4 @@ }

const useMergedRef = (...args) => {
return (0, _react.useCallback)(element => {
const useMergedRef = (...args) =>
(0, _react.useCallback)(element => {
if (args.length === 2) {

@@ -24,8 +24,7 @@ setRef(args[0], element)

} else {
for (let ref of args) setRef(ref, element)
for (const ref of args) setRef(ref, element)
}
}, args)
}
var _default = useMergedRef
exports.default = _default

@@ -6,3 +6,3 @@ import {useCallback} from 'react'

ref(value)
} else if (ref !== null) {
} else if (ref !== null && typeof ref === 'object') {
ref.current = value

@@ -12,4 +12,4 @@ }

const useMergedRef = (...args) => {
return useCallback(element => {
const useMergedRef = (...args) =>
useCallback(element => {
if (args.length === 2) {

@@ -19,7 +19,6 @@ setRef(args[0], element)

} else {
for (let ref of args) setRef(ref, element)
for (const ref of args) setRef(ref, element)
}
}, args)
}
export default useMergedRef
{
"name": "@react-hook/merged-ref",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://github.com/jaredLunde/react-hook/tree/master/packages/merged-ref#readme",
"repository": "github:jaredLunde/react-hook",
"bugs": "https://github.com/jaredLunde/react-hook/issues",
"author": "Jared Lunde <jared@BeStellar.co> (https://jaredLunde.com)",
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/es/index.js",
"files": [
"/dist"
],
"description": "A React hook for merging multiple refs into one ref",

@@ -20,62 +18,58 @@ "keywords": [

],
"main": "dist/cjs/index.js",
"module": "dist/es/index.js",
"files": [
"/dist"
],
"sideEffects": false,
"devDependencies": {
"@babel/preset-react": "latest",
"@lunde/babel-preset-es": "latest",
"@testing-library/jest-dom": "latest",
"@testing-library/react": "latest",
"@testing-library/react-hooks": "latest",
"babel-eslint": "latest",
"cross-env": "latest",
"eslint": "latest",
"eslint-import-resolver-jest": "latest",
"eslint-plugin-jest": "latest",
"eslint-plugin-react": "latest",
"eslint-plugin-react-hooks": "latest",
"husky": "latest",
"jest": "latest",
"lint-staged": "latest",
"prettier": "latest",
"pretty-quick": "latest",
"react": "latest",
"react-dom": "latest",
"react-test-renderer": "latest",
"rimraf": "^2.6.3"
},
"dependencies": {},
"peerDependencies": {
"react": ">=16.8.0"
},
"scripts": {
"build": "npm run build:cjs && npm run build:es",
"build:cjs": "babel src -d dist/cjs -x .js --ignore \"**/*.test.js\",\"**/test.js\" --delete-dir-on-start",
"build:es": "cross-env BABEL_ENV=es babel src -d dist/es -x .js --ignore \"**/*.test.js\",\"**/test.js\" --delete-dir-on-start",
"format": "prettier --write \"**/*.{js,jsx,yml,md}\"",
"lint": "eslint src",
"build": "npm run build:cjs && npm run build:es && npm run build:types",
"build:cjs": "babel src -d dist/cjs -x .ts --ignore \"**/*.test.ts\",\"**/test.ts\" --delete-dir-on-start",
"build:es": "babel src -d dist/es -x .ts --env-name es --ignore \"**/*.test.ts\",\"**/test.ts\" --delete-dir-on-start",
"build:types": "tsc -p tsconfig.json -d --outDir dist/es --emitDeclarationOnly && mkdir -p dist/cjs && cp -R dist/es/**.d.ts dist/cjs && rimraf dist/**/*.test.d.ts",
"check-types": "tsc --noEmit -p tsconfig.json",
"format": "prettier --write \"**/*.{ts,js,md,yml,json,babelrc,eslintrc,prettierrc}\"",
"lint": "eslint . --ext .ts",
"prepublishOnly": "npm run lint && npm run test && npm run build && npm run format",
"test": "jest",
"validate": "npm run lint && npm run test -- --coverage"
"validate": "npm run check-types && npm run lint && npm run test -- --coverage"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "lint-staged && npm run build:types"
}
},
"lint-staged": {
"src/**/*.js": [
"**/*.{ts,js}": [
"eslint",
"pretty-quick --staged"
"prettier --write"
],
"**/*.{md,yml}": [
"pretty-quick --staged"
"**/*.{md,yml,json}": [
"prettier --write"
]
},
"homepage": "https://github.com/jaredLunde/react-hook/tree/master/packages/merged-ref#readme",
"repository": {
"type": "git",
"url": "https://github.com/jaredLunde/react-hook.git"
"devDependencies": {
"@lunde/babel-preset-es": "latest",
"@testing-library/react": "^9.3.2",
"@testing-library/react-hooks": "^3.2.1",
"@types/jest": "latest",
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest",
"cross-env": "latest",
"eslint": "latest",
"eslint-import-resolver-jest": "latest",
"eslint-plugin-jest": "latest",
"husky": "latest",
"jest": "latest",
"lint-staged": "latest",
"prettier": "latest",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-test-renderer": "^16.12.0",
"rimraf": "^2.6.3",
"ts-jest": "latest",
"typescript": "latest"
},
"bugs": {
"url": "https://github.com/jaredLunde/react-hook/issues"
}
"dependencies": {},
"peerDependencies": {}
}

@@ -1,18 +0,30 @@

[![bundlephobia](https://img.shields.io/bundlephobia/minzip/@react-hook/merged-ref?style=plastic)](https://bundlephobia.com/result?p=@react-hook/merged-ref)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://jaredlunde.mit-license.org/)
<hr>
<div align="center">
<h1 align="center">
@react-hook/merged-ref
</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="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>
# @react-hook/merged-ref
<pre align="center">npm i @react-hook/merged-ref</pre>
<hr>
A React hook for merging multiple refs into one ref
## Installation
## Quick Start
#### `npm i merged-ref`
#### `yarn add merged-ref`
## Usage
```jsx harmony

@@ -22,3 +34,3 @@ import React from 'react'

const F = React.forwardRef((props, ref) => {
const Component = React.forwardRef((props, ref) => {
const otherRef = React.useRef(null)

@@ -30,4 +42,16 @@ const multiRef = useMergedRef(ref, otherRef)

## 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
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc