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">