2015-04-17 10 views

risposta

29

quello che vuoi è dangerouslySetInnerHTML

https://facebook.github.io/react/tips/dangerously-set-inner-html.html

function createMarkup() { return {__html: 'First · Second'}; }; 
<div dangerouslySetInnerHTML={createMarkup()} /> 

Edit: si vorrà HTMLEncode la stringa.

+0

Che cosa si intende per HTMLEncode? Potresti espandere il tuo esempio? Sono interessato a disinfettare l'html. Grazie – RobSeg

+1

Voglio dire usare le entità html quando necessario, come > e < invece di> e < – SnareHanger

Problemi correlati