Use template literals
Template literals allow the use of multi-line strings which preserve leading/trailing white-space and new lines.
class SomeComponent extends React.Component {
render() {
return (
<pre>{`
Hello ,
World .
`}</pre>
)
}
}
class SomeComponent extends React.Component {
render() {
return (
<pre>{`
Hello ,
World .
`}</pre>
)
}
}
ReactDOM.render(
<SomeComponent />,
document.getElementById('pre')
)
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react-dom.min.js"></script>
<!-- The content rendered into this tag should match the content below. -->
<div id="pre"></div>
<pre>
Hello ,
World .
</pre>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…