LoginSignup
0
0

More than 1 year has passed since last update.

Next.js で path 要素の stroke-linecap 属性を設定すると warning がでる

Last updated at Posted at 2023-03-29

Next.js 13 で path の属性に stroke-linecap を指定したら、warning がでた。

ソースコード

<svg className="w-2.5 h-2.5 text-pink-200" width="16" height="16" viewBox="0 0 16 16" fill="none">
    <path d="M5.27921 2L10.9257 7.64645C11.1209 7.84171 11.1209 8.15829 10.9257 8.35355L5.27921 14" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
</svg>

warning の内容

Warning: Invalid DOM property `stroke-width`. Did you mean `strokeWidth`?

...

    at Body (/Users/centipede/works/sample-project/node_modules/next/dist/server/render.js:620:21)
Warning: Invalid DOM property `stroke-linecap`. Did you mean `strokeLinecap`?

解決策

svg 要素に xmlns="http://www.w3.org/2000/svg" 属性を追加すれば、warning は表示されなくなる。

<svg xmlns="http://www.w3.org/2000/svg" className="w-2.5 h-2.5 text-pink-200" width="16" height="16" viewBox="0 0 16 16" fill="none">
0
0
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
0
0