您正在使用@emotion/core
,它使用css
道具,但是您将样式标记传递给className
道具,如果您使用emotion
需要额外设置以使服务器端渲染工作的包,您将这样做。有关比较和更多详细信息,请参阅文档中的此页面。
解决方法是首先删除css()
围绕样式对象文字的函数调用:
// replace this
export const header = css({
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
flexWrap: "wrap",
marginTop: "1.5rem",
});
// with this
export const header = {
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
flexWrap: "wrap",
marginTop: "1.5rem",
}
然后替换className
为css
您传递的要使用 Emotion 的对象或数组的任何位置:
// 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>