【发布时间】:2022-12-26 01:13:16
【问题描述】:
不断收到此错误,我有我的app directory 并尝试为页面转换设置动画,但无论我对 framer motion 做什么,我都会收到此 v8 错误。找不到周围的很多东西,有没有人有解决办法?
'use client';
import { Poppins } from '@next/font/google';
import { useRouter, React } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { getSession } from '../lib/session';
import Header from '../components/Header';
import Footer from '../components/Footer';
import AuthContext from '../components/AuthContext';
import '../styles/globals.css';
// If loading a variable font, you don't need to specify the font weight
const poppins = Poppins({
weight: '500',
});
export default async function RootLayout({ children }) {
const session = await getSession();
const router = useRouter();
return (
<html lang="en" className={poppins.className}>
<head />
<body>
<AuthContext session={session}>
<Header />
<AnimatePresence exitBeforeEnter>
<motion.div
key={router.route}
initial="initialState"
animate="animateState"
exit="exitState"
transition={{
duration: 0.75,
}}
variants={{
initialState: {
opacity: 0,
clipPath: 'polygon(0 0, 100% 0, 100% 100%, 0% 100%)',
},
animateState: {
opacity: 1,
clipPath: 'polygon(0 0, 100% 0, 100% 100%, 0% 100%)',
},
exitState: {
clipPath: 'polygon(50% 0, 50% 0, 50% 100%, 50% 100%)',
},
}}
>
{children}
</motion.div>
</AnimatePresence>
</AuthContext>
{session ? <Footer /> : ''}
</body>
</html>
);
}
也许它与 nextAuth 有关?不确定
【问题讨论】:
-
我认为你的问题与在服务器端调用 framerMotion 有关,因为 v8 是浏览器的引擎......但不幸的是我还没有使用 framer motion 来做出反应......
-
@Wraithy 我在上面添加了
'use client';使其成为客户端呈现的组件,但我仍然收到错误
标签: reactjs next.js framer-motion