Replace part of string in WYSIWYG editor using JSX
P粉060112396
2023-08-17 10:28:01
<p>I have a string provided by WYSIWYG editor input, for example: </p>
<pre class="brush:js;toolbar:false;">const originalString = "<div>Some text</div><strong>Some bold text{{response}}</strong> ";
</pre>
<p>I need to replace <code>{{response}}</code> with some JSX and output the result as HTML. </p>
<p>I don't think I can use <code>dangerouslySetInnerHTML</code> because it doesn't handle JSX. Instead, you get the following output: </p>
<pre class="brush:html;toolbar:false;"><div>Some text</div>
<strong>Some bold text [object Object]</strong>
</pre>
<p>View examples here. </p>
<p>Is there a way to replace <code>{{response}}</code> with JSX and then convert the rest of the string to valid HTML when rendering? </p>
Is this what you want?