I have a HTML content as string for eg <div>Hello</div>
and I just want to render it as HTML in react component without using innerHTML method and default react like dangerouslySetInnerHTML. Let me know if there is any perfect alternative which will work effectively. I just do not want to use any package like html-to-react. Is it possible to achieve it with any other default method in React Render?
export default class sampleHTML extends React.Component {
constructor(props) {
super(props);
this.state = {
currentState: "",
};
}
componentDidMount() {
this.setState({currentState :`<div>Hello</div>` });
}
render() {
return (
<div id="container">{this.state.currentState}</div>
)
};
};
I need to render tags not as string