Next.jsとemotionで次のようなエラーがでた
The pseudo class ":nth-child" is potentially unsafe when doing server-side rendering. Try changing it to ":nth-of-type".
:nth-child
はSSRでundafeらしい。なんでたかが:nth-child
がunsafeなの?と思ったけどどうやら
このissueをみてるかんじ、兄要素として <style>
が挿入されることがあるそうな。解決策については
公式のドキュメントのSSRのページにのっています
SSRではない場合、このエラーを非表示にしたい事はあると思うんだけど
この記述が必要らしい
span:nth-child(2) /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ {
animation-delay: 0.2s;
}
span:nth-child(4) /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ {
animation-delay: 0.4s;
}
うーん、流石にちょっとこれは普通につけられるのであれば、クラスつけたほうがいいんじゃない?となっちゃいますね……