-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Framer Motion causes the error: 'AnimatePresence' cannot be used as a JSX component. #8195
Comments
I noticed in the linked reproduction that you have both AFAIK, Framer Motion is not compatible with Preact (or |
@natemoo-re However, TypeScript is still throwing the following errors:
I'm not sure how to solve these. |
These are just type errors from TypeScript in your editor. Astro requires a Try changing {
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"jsx": "react-jsx",
- "jsxImportSource": "preact",
+ "jsxImportSource": "react",
"allowImportingTsExtensions": true,
"baseUrl": ".",
"paths": { "@/*": ["src/*"] }
}
} |
After making that change locally, I can see that the error goes away, so I'm going to close this! |
@natemoo-re That works. Thanks for your help! |
What version of
astro
are you using?2.9.6
Are you using an SSR adapter? If so, which one?
none
What package manager are you using?
npm
What operating system are you using?
Windows
What browser are you using?
Chrome, Firefox
Describe the Bug
I am creating a gallery that uses an animation method found in the Framer Motion library, but I ran into a problem making it work.
To animate the gallery, the component AnimatePresence is used to wrap around React components to be animated and the keyword 'motion' is added in front of an HTML tag name.
For example:
I made sure that the React component has the correct directive:
However, the following TypeScript to appears when I implemented the code:
Also, the website crashes on runtime and the following error appears in the terminal:
Here is the page where I implemented AnimatedPresence method:
https://github.com/Albertyhu/uthan-template/blob/with-framer/src/components/project/gallery/gallery-react.tsx
Here is the page where motion.div is implemented:
https://github.com/Albertyhu/uthan-template/blob/with-framer/src/components/project/gallery/masonry-item.tsx
I noticed that I received a similar TypeScript error when I tried to use other React packages such React-Counter. Thus, this issue is less likely to be isolated to just Framer Motion.
I appreciate any help I can get here.
What's the expected result?
The gallery should be animated as shown in the following video:
https://youtu.be/f4f7vwL4TcQ?t=26
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-vzn4fz?file=src%2Fpages%2Findex.astro,astro.config.mjs,src%2Fcomponents%2Fgallery%2Findex.astro,src%2Fcomponents%2Fgallery%2Fgallery-react.tsx,tsconfig.json,src%2Futil%2FatomItems.js,src%2Fcomponents%2Fgallery%2Fmasonry-item.tsx,src%2Fdemo%2Fprojects.json&on=stackblitz
Participation
The text was updated successfully, but these errors were encountered: