Comparing version 5.21.1 to 5.21.2
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import * as React from 'react'; | ||
function getUseId() { | ||
// We need fully clone React function here to avoid webpack warning React 17 do not export `useId` | ||
var fullClone = _objectSpread({}, React); | ||
return fullClone.useId; | ||
} | ||
var uuid = 0; | ||
@@ -12,4 +21,2 @@ /** @private Note only worked in develop env. Not work in production. */ | ||
export default function useId(id) { | ||
var _React$useId; | ||
// Inner id for accessibility usage. Only work in client side | ||
@@ -19,8 +26,8 @@ var _React$useState = React.useState('ssr-id'), | ||
innerId = _React$useState2[0], | ||
setInnerId = _React$useState2[1]; // eslint-disable-next-line react-hooks/rules-of-hooks | ||
setInnerId = _React$useState2[1]; | ||
var reactNativeId = (_React$useId = React.useId) === null || _React$useId === void 0 ? void 0 : _React$useId.call(React); | ||
var useOriginId = getUseId(); | ||
var reactNativeId = useOriginId === null || useOriginId === void 0 ? void 0 : useOriginId(); | ||
React.useEffect(function () { | ||
if (!React.useId) { | ||
if (!useOriginId) { | ||
var nextId = uuid; | ||
@@ -27,0 +34,0 @@ uuid += 1; |
@@ -15,4 +15,12 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var React = _interopRequireWildcard(require("react")); | ||
function getUseId() { | ||
// We need fully clone React function here to avoid webpack warning React 17 do not export `useId` | ||
var fullClone = (0, _objectSpread2.default)({}, React); | ||
return fullClone.useId; | ||
} | ||
var uuid = 0; | ||
@@ -28,4 +36,2 @@ /** @private Note only worked in develop env. Not work in production. */ | ||
function useId(id) { | ||
var _React$useId; | ||
// Inner id for accessibility usage. Only work in client side | ||
@@ -35,8 +41,8 @@ var _React$useState = React.useState('ssr-id'), | ||
innerId = _React$useState2[0], | ||
setInnerId = _React$useState2[1]; // eslint-disable-next-line react-hooks/rules-of-hooks | ||
setInnerId = _React$useState2[1]; | ||
var reactNativeId = (_React$useId = React.useId) === null || _React$useId === void 0 ? void 0 : _React$useId.call(React); | ||
var useOriginId = getUseId(); | ||
var reactNativeId = useOriginId === null || useOriginId === void 0 ? void 0 : useOriginId(); | ||
React.useEffect(function () { | ||
if (!React.useId) { | ||
if (!useOriginId) { | ||
var nextId = uuid; | ||
@@ -43,0 +49,0 @@ uuid += 1; |
{ | ||
"name": "rc-util", | ||
"version": "5.21.1", | ||
"version": "5.21.2", | ||
"description": "Common Utils For React Component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
196854
6030