carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.84k stars 1.81k forks source link

[Bug]: useId giving warning as it's not supported by react <18 #17084

Closed sean-anderson-ibm closed 2 months ago

sean-anderson-ibm commented 2 months ago

Package

@carbon/react

Browser

No response

Package version

v1.63.0

React version

16.14.0

Description

A recent PR - https://github.com/carbon-design-system/carbon/pull/16988, which was part of the v1.63.0 release of @carbon/react has moved to using useId in more places. There is handling for the correct version here https://github.com/carbon-design-system/carbon/blob/f22da5a696bd891a58aa0fc4c81f0fbe0030ba5d/packages/react/src/internal/useId.js#L26 but this seems to not be working since that PR.

When running a storybook-smoke-test (npm run storybook-smoke-test) we are seeing:

WARN export 'useId' (imported as 'useId') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, version)

I believe the initial PR to fix this was https://github.com/carbon-design-system/carbon/pull/14153, and I can't see that file being changed since so it's not immediately obvious why it's no longer working.

Reproduction/example

react@16.14.0, @carbon/react@1.63.0

Steps to reproduce

Suggested Severity

Severity 1 = Must be fixed ASAP. The response must be swift. Someone from the team must drop all current work and be immediately reassigned to address the issue.

Application/PAL

Cloud Pak For Integration (Platform UI)

Code of Conduct

guidari commented 2 months ago

We can guard the useId hook for React versions lower than 18 by using a smiliar approach that we applied here:

https://github.com/carbon-design-system/carbon/blob/d594e9bf355cf31bda800bbb4789147cb60c781b/packages/react/src/internal/useId.js#L68-L71

tom-youd commented 2 months ago

Can this be reopened? We are still seeing this warning with @carbon/react:1.63.1