0

We have created spfx react project for SharePoint online using type script:

Here, props.appendTextDetails value is "Go to GoogleSearch on spfx react project".

const FCRichtext = (props:any) => {

return <div>
  <Label>{props.appendTextDetails}</Label>
</div>

}; export default FCRichtext;

How can we render the HTML value?

2 Answers 2

2

You can use dangerouslySetInnerHTML attribute to add the HTML.

Modify your code as below:

return <div>
  <Label><div dangerouslySetInnerHTML={props.appendTextDetails} /></Label>
</div>

React DOM elements

0

You can use React render html package. https://www.npmjs.com/package/react-render-html

import renderHTML from 'react-render-html';

render() {
return (
  <div className='sample'>
    {renderHTML(someHTML)}
  </div>
);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.