0
0

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 1 year has passed since last update.

validateDOMNesting が出たがどこだかわからない〜!!が5秒で解決する方法

Posted at
Warning: validateDOMNesting(...): <div> cannot appear as a descendant of <p>.

こういうエラーが出るときがある。
簡単に言えば
<p> の子要素に <div> 入れるな!! それはブラウザルール違反!!!」
(は?動くが?)という気持ちになるが、一応今のHTMLの仕様上はそうなってる。
ほかには <table> タグに <tbody> がなかったり、 <a> の中に <a> がネストしてたりすると発生する。

参考:

は?そんなDOM要素作って無いんだが?

これもよくある。何らかのライブラリが pタグで作っているのが原因であり、ゆえに原因行が特定出来ないのだ。

解決方法というか調査方法はシンプルで、Chrome等のデバッグコンソールで調べるだけ。

Reactのソース上でどのようなDOM(jsx)でマークアップされていようが、最終的に出るHTMLの方を調べてしまえばいい。
ここでは、閉じタグ </p> で検索するのがコツだろうか。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?