본문 바로가기
React/오류 모음집

react) dangerouslySetInnerHTML 사용 시 에러

by YUYU_ 2022. 8. 29.

에러 내용

나의 코드 

<div dangerouslySetInnerHTML={{ __html: content }} > </div>/

 

구글링하고 문서를 뒤져봐도 전혀 틀린 내용이 없다고 생각했다. 하지만 오류 해결은 생각보다 간단했다.

 

오류의 해결에 도움이 된 stackoverflow글은 다음과 같다. 

 

https://stackoverflow.com/questions/36787086/can-only-set-one-of-children-or-props-dangerouslysetinnerhtml

 

Can only set one of `children` or `props.dangerouslySetInnerHTML`

I'm trying to set the inner HTML of an alert div, but receiving the error message : Can only set one of 'children' or props.dangerouslySetInnerHTML'. Why does this happen ? function alertContent(...

stackoverflow.com

 

<div> </div> 사이에 공백이 있어서 발생한 오류였다... 

 

공백을 지우니 잘 작동했다.