Following is my react code block
import React from 'react';
import { render } from 'react-dom';
import Parser from 'html-react-parser';
var styles = {
primaryLable60: {
fontSize: '60px',
color: '#dedede',
direction: 'ltr',
textAlign: '-webkit-auto',
}
};
var htmlString = "<div style={styles.primaryLable60}>Hello World</div>";
const renderRoot = document.getElementById('root');
render(
<div>
{Parser(htmlString)}
<div style={styles.primaryLable60}>
Hello World
</div>
</div>
, renderRoot)
I need to get the actual "styles.primaryLable60" style object while rendering.
New to react, so need help on it
Use
dangerouslySetInnerHTML
.Instead of
no need to use
html-react-parser
.may be you have to use if you really need Parser.
refer here about react-html-parser