λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
πŸ’› Frontend/πŸ’› Frontend : React

<React> <p> cannot appear as a descendant of <p> 해결방법

by eyes from es 2022. 10. 26.
728x90
λ°˜μ‘ν˜•

μš”λŸ° μ—λŸ¬κ°€ λ°œμƒν•œ 상황!!

μ½”λ“œλŠ” λ™μž‘ν•˜μ§€λ§Œ μ—λŸ¬κ°€ λ°œμƒν•΄μ„œ κ±°μŠ¬λ¦°λ‹€

 

μ™œμΈμ§€ App.js μ½”λ“œ μ–΄λ””μ—μ„œ 였λ₯˜κ°€ λ‚œ 것인지 라인 λ„˜λ²„κ°€ 보이지 μ•ŠλŠ”λ‹€.

일단 였λ₯˜ λ‚΄μš©μ„ 보면 <p>μ•ˆμ— <div>κ°€ 있으면 μ•ˆλœλ‹€? λŠ” 뜻인 λ“―

 

 

이건 App.jsμ½”λ“œ 일뢀

 

 

https://stackoverflow.com/questions/41928567/div-cannot-appear-as-a-descendant-of-p

 

<div> cannot appear as a descendant of <p>

I'm seeing this. It's not a mystery what it is complaining about: Warning: validateDOMnesting(...): <div> cannot appear as a descendant of <p>. See ... SomeComponent > p > ... >

stackoverflow.com

 

🎯 μ •λ¦¬ν•˜λ©΄,

<p>μ•ˆμ— <div> μš”μ†Œκ°€ 있으면 μ•ˆλœλ‹€λŠ” 뜻

<div>λŠ” block μš”μ†Œμ΄κ³ , <p>λŠ” inline μš”μ†ŒλΌμ„œ,

inline μ•ˆμ— block이 λ“€μ–΄κ°€λ©΄ warning λ°œμƒ

 

 

🎯 ν•΄κ²°μ±…!

<p>νƒœκ·Έλ₯Ό <div>둜 λ„£μ–΄μ£Όλ©΄ λœλ‹€

728x90
λ°˜μ‘ν˜•