use-composed-ref
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -7,2 +7,8 @@ 'use strict'; | ||
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefault(React); | ||
// basically Exclude<React.ClassAttributes<T>["ref"], string> | ||
var updateRef = function updateRef(ref, value) { | ||
@@ -15,18 +21,13 @@ if (typeof ref === 'function') { | ||
}; | ||
var useComposedRef = function useComposedRef(libRef, userRef) { | ||
var prevUserRef = React.useRef(); | ||
return React.useCallback(function (instance) { | ||
var prevUserRef = React__default["default"].useRef(); | ||
return React__default["default"].useCallback(function (instance) { | ||
libRef.current = instance; | ||
if (prevUserRef.current) { | ||
updateRef(prevUserRef.current, null); | ||
} | ||
prevUserRef.current = userRef; | ||
if (!userRef) { | ||
return; | ||
} | ||
updateRef(userRef, instance); | ||
@@ -36,2 +37,2 @@ }, [userRef]); | ||
exports.default = useComposedRef; | ||
exports["default"] = useComposedRef; |
@@ -1,3 +0,5 @@ | ||
import { useRef, useCallback } from 'react'; | ||
import React from 'react'; | ||
// basically Exclude<React.ClassAttributes<T>["ref"], string> | ||
var updateRef = function updateRef(ref, value) { | ||
@@ -10,18 +12,13 @@ if (typeof ref === 'function') { | ||
}; | ||
var useComposedRef = function useComposedRef(libRef, userRef) { | ||
var prevUserRef = useRef(); | ||
return useCallback(function (instance) { | ||
var prevUserRef = React.useRef(); | ||
return React.useCallback(function (instance) { | ||
libRef.current = instance; | ||
if (prevUserRef.current) { | ||
updateRef(prevUserRef.current, null); | ||
} | ||
prevUserRef.current = userRef; | ||
if (!userRef) { | ||
return; | ||
} | ||
updateRef(userRef, instance); | ||
@@ -31,2 +28,2 @@ }, [userRef]); | ||
export default useComposedRef; | ||
export { useComposedRef as default }; |
{ | ||
"name": "use-composed-ref", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "React hook which creates a ref function from given refs. Useful when using forwardRef.", | ||
"main": "./dist/use-composed-ref.cjs.js", | ||
"module": "./dist/use-composed-ref.esm.js", | ||
"types": "./types/index.d.ts", | ||
"main": "dist/use-composed-ref.cjs.js", | ||
"module": "dist/use-composed-ref.esm.js", | ||
"exports": { | ||
".": { | ||
"types": { | ||
"import": "./dist/use-composed-ref.cjs.mjs", | ||
"default": "./dist/use-composed-ref.cjs.js" | ||
}, | ||
"module": "./dist/use-composed-ref.esm.js", | ||
"import": "./dist/use-composed-ref.cjs.mjs", | ||
"default": "./dist/use-composed-ref.cjs.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"types": "./dist/use-composed-ref.cjs.d.ts", | ||
"files": [ | ||
"dist", | ||
"types" | ||
"dist" | ||
], | ||
"scripts": { | ||
"test": "echo \"Warning: no test specified\" || jest --env=node", | ||
"prebuild": "rimraf dist types", | ||
"build": "rollup -c && tsc", | ||
"build": "preconstruct build", | ||
"preversion": "npm test", | ||
@@ -29,4 +39,9 @@ "prepare": "npm run build" | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@types/react": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
@@ -37,2 +52,3 @@ "@babel/core": "^7.3.4", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"@preconstruct/cli": "^2.8.10", | ||
"@types/react": "^16.8.8", | ||
@@ -44,7 +60,12 @@ "husky": "^1.3.1", | ||
"react": "^16.8.4", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.6.0", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"typescript": "^4.5.4" | ||
"typescript": "^5.7.2" | ||
}, | ||
"preconstruct": { | ||
"exports": { | ||
"importConditionDefaultExport": "default" | ||
}, | ||
"___experimentalFlags_WILL_CHANGE_IN_PATCH": { | ||
"importsConditions": true | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4863
12
10
63