dangerously-set-html-content-v1 icon indicating copy to clipboard operation
dangerously-set-html-content-v1 copied to clipboard

How to remove old content after get new content?

Open nhatcuongboy opened this issue 2 years ago • 1 comments

When I get content from API, it will be dynamic. let data = callApi(); <InnerHTML html={data} />

My data look like:

<form>
<p>{title}</p>
</form>
<script>
function test(){}
</script>

Now, how to remove old content after get new content? Because, after get new content, It will notify some error like: "Uncaught SyntaxError: Identifier 'form' has already been declared"

Please help me this issue. Thanks

nhatcuongboy avatar Nov 10 '22 09:11 nhatcuongboy

I'll change as long as you properly update the content, this repo contains an example of how to do it, also, not sure if the interpolation will work here: {title} since all the content rendered will be outside React context

christo-pr avatar Nov 10 '22 22:11 christo-pr