-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
[BUG] export 'useId' (imported as 'React') was not found in 'react' (related to React 18 upgrade?) (v6.2.5) #1447
Comments
The solution for us was:
|
Same here for both problem and solution, cheers! Next.js with it's webpack build pre-downgrade:
Similar issue at Material UI: |
No problems here running 6.2.5 locally. The deployment seems also ok with Next / Vercel. The useId function is not from React but an internal version of framer-motion added in the commit mentioned above. Update: Please ignore this comment. |
In my application, I still use React v17 which breaks due to this module using
If this module requires v18, it should be defined as |
I am trying to use "framer-motion" in a project but my React code failed to compile; please how can I fix it? These are the errors I'm getting. Failed to compile. Attempted import error: 'useId' is not exported from 'react' (imported as 'useId'). ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs 50:2-20 ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs 17:13-18 ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs 38:13-18 webpack compiled with 4 errors |
I am also having this problem when running this code on newest Framer Motion version. When I'll find a fix, I'll tell you. EDIT: Fixed it! Test this solution that worked for me. It's actually quite easy and hilarious. If you look at Framer Motion update guides you can see that Framer Motion v7 makes React 18 the minimum supported version. I'm using React 17.0.2 which explains the errors when trying to use a Framer Motion v7. All you have to do is uninstall the current Framer Motion package you have installed and install an older package. Checking which v6 version to use Installing the latest Framer Motion v6 package. I use --legacy-peer-deps as I have NPM v8 and have noticed it causes some issues without it. |
Compiled with problems:X ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs 40:13-18 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) ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs 58:2-20 export 'useInsertionEffect' (imported as 'useInsertionEffect') 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) ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs 18:13-18 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) ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs 37:13-18 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) ERROR in ./node_modules/framer-motion/dist/es/motion/utils/use-visual-element.mjs 34:2-20 export 'useInsertionEffect' (imported as 'useInsertionEffect') 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) ERROR in ./node_modules/framer-motion/dist/es/utils/use-motion-value-event.mjs 10:2-20 export 'useInsertionEffect' (imported as 'useInsertionEffect') 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) ERROR in ./node_modules/framer-motion/dist/es/value/use-spring.mjs 41:2-20 export 'useInsertionEffect' (imported as 'useInsertionEffect') 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) am facing this erroe |
I had the same problem. @annaozola solution fixed it perfectly. Thanks! |
@annaozola your solution works wonderfully for me, thank you! |
I was using react17 upgrading to 18 fixed the issue for me. |
1. Read the FAQs 👇
2. Describe the bug
Possibly related to React 18 upgrade?
986fd3f
The text was updated successfully, but these errors were encountered: