你正在使用
@emotion/core
,它使用
css
属性,但你将你的样式令牌传递给了
className
属性。如果你使用的是需要额外设置才能使服务器端渲染工作的
emotion
包,则应该这样做。
请参阅文档中的此页面进行比较和更多细节说明。
解决方法是首先移除你的
css()
函数调用,然后在你的样式对象文字周围添加
css` `
模板字符串。
export const header = css({
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
flexWrap: "wrap",
marginTop: "1.5rem",
});
export const header = {
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
flexWrap: "wrap",
marginTop: "1.5rem",
}
然后,无论您在何处传递要使用Emotion处理的对象或数组,都将className
替换为css
:
// replace this
<header className={styles.header}>
<h1 className={styles.heading}>
<Link className={styles.headingLink} to={`/`}>
{title}
</Link>
</h1>
<Bio />
</header>
// with this
<header css={styles.header}>
<h1 css={styles.heading}>
<Link css={styles.headingLink} to={`/`}>
{title}
</Link>
</h1>
<Bio />
</header>