7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

emotion で The pseudo class ":nth-child" is potentially unsafe when doing server-side rendering. Try changing it to ":nth-of-type".

Last updated at Posted at 2020-01-22

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;
}

うーん、流石にちょっとこれは普通につけられるのであれば、クラスつけたほうがいいんじゃない?となっちゃいますね……

7
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?