[BUG] AnimatePresence cannot be used as a JSX component
Describe the bug
Since today I am keeping this error related to AnimatePresence, yesterday was working well.
Provide a CodeSandbox reproduction of the bug
ERROR in src/pages/..../MyPage.tsx:33:10
TS2786: 'AnimatePresence' cannot be used as a JSX component.
Its return type 'Element | undefined' is not a valid JSX element.
31 | <div className={styles.BodyContainer}>
32 | <Accordion onToggle={handleToggle} openItems={openItems} multiple collapsible>
> 33 | <AnimatePresence>
| ^^^^^^^^^^^^^^^
34 | {appGroups?.map((group: IGroup, index: number) => (
35 | <Group
36 | key={group.motionId}
Steps to reproduce
NodeJS version: 16.20.0
React versions: "@types/react": "^18.2.6", "@types/react-dom": "^18.2.4"
Just run: npm start
Expected behavior
Justo keep working
[I think it's this line: (https://github.com/motiondivision/motion/blob/a7926e2a41a1c1f76895db848ecc2ab8446a4458/packages/framer-motion/src/components/AnimatePresence/index.tsx#L149)
If you replace:
/**
* Early return to ensure once we've set state with the latest diffed
* children, we can immediately re-render.
*/
return
with
/**
* Early return to ensure once we've set state with the latest diffed
* children, we can immediately re-render.
*/
return <></>;
The return type should change to just JSX.Element
Same issue
same issue
Yep I got the same issue
Will take a look tomorrow!
I had this error on react 18, upgrade to react 19 if possible, will go away
Can you try 12.0.8-alpha.0 to see if this fixes it for you?
Can you try
12.0.8-alpha.0to see if this fixes it for you?
Ok I'll give it a try!
How was it @RicBruIAI ?
How was it @RicBruIAI ?
I tried it, and it worked! Just remember to delete node_modules + lock file and reinstall dependencies.
Thanks for the fix @mattgperry 👍🏾 Hope it works for others too.
It is working! thank you all!