React: Script tag not working when inserted using dangerouslySetInnerHTML

后端 未结 5 1371
甜味超标
甜味超标 2020-11-28 12:29

I\'m trying to set html sent from my server to show inside a div using dangerouslySetInnerHTML property in React. I also have script tag inside it and use functions defined

5条回答
  •  广开言路
    2020-11-28 13:11

    I created a React component that works pretty much like dangerouslySetInnerHtml but additionally it executes all the js code that it finds on the html string, check it out, it might help you:

    https://www.npmjs.com/package/dangerously-set-html-content

提交回复
热议问题