Replace the text {{timer}} with react component
waqas61 opened this issue · comments
Using reactStringReplace react node package and dangerouslySetInnerHTML to replace the specific text with react component
Editor content text to replace {{timer}} good day
this.onChange = (editorState) => {
this.setState({
editorState,
editorContentHtml: convertToHTML(
editorState.getCurrentContent()
),
});
let replacedText;
replacedText = reactStringReplace(
this.state.editorContentHtml,
/({{timer}})/g,
(match, i) => (
<EventCountdown value="2022-06-10T00:00:00+01:00" />
)
);
this.setState({
template: replacedText,
});
};
<p
dangerouslySetInnerHTML={{
__html: this.state.template,
}}
></p>
it does not work. In Dom, it looks like text to replace [object Object] good day
where did you get that convertToHTML