Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings for importing useId if React < 18 #357

Open
crucialfelix opened this issue Oct 6, 2022 · 1 comment
Open

Warnings for importing useId if React < 18 #357

crucialfelix opened this issue Oct 6, 2022 · 1 comment

Comments

@crucialfelix
Copy link

crucialfelix commented Oct 6, 2022

WARNING in ./node_modules/react-accessible-accordion/dist/es/index.js 548:16-21

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)

This attempts to import from React:

import { createElement, PureComponent, createContext, useId, useState, Fragment } from 'react';

but useId is only in React 18.

It would be better to import React and then check if 'useId' is a defined property.

@crucialfelix crucialfelix changed the title Import fails for < React 18 Warnings for importing useId if React < 18 Oct 6, 2022
@gbhasha
Copy link

gbhasha commented Feb 5, 2023

I have design system which uses React18 and [email protected].

When i use my design library on a React17.x project, i am getting the ERROR as shown below...

Seems v5.0.0 is not compatible with React<18.

ERROR in ../../node_modules/react-accessible-accordion/dist/es/index.js 548:16-21
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants