From 4795cef4c4ca0dc79763d259c7889fb524217afe Mon Sep 17 00:00:00 2001 From: Yixuan Xu Date: Sun, 17 Apr 2022 13:19:47 +0800 Subject: [PATCH] chore: use useId to detect react version --- src/utils/helper.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/helper.ts b/src/utils/helper.ts index cd99e9d822..e23c457657 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -1,4 +1,4 @@ -import { version } from 'react' +import React from 'react' export const noop = () => {} // Using noop() as the undefined value as undefined can possibly be replaced @@ -6,7 +6,9 @@ export const noop = () => {} // to ensure that tsc doesn't remove the __NOINLINE__ comment. // prettier-ignore export const UNDEFINED = (/*#__NOINLINE__*/ noop()) as undefined -export const IS_REACT_LEGACY = !version.startsWith('18') + +// @ts-expect-error TODO: should remove this when the default react version is 18 +export const IS_REACT_LEGACY = !React.useId export const OBJECT = Object export const isUndefined = (v: any): v is undefined => v === UNDEFINED