1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-10 12:24:20 +01:00
ipfs-boards/webapp/components/markdown.jsx
2015-12-14 00:29:25 +01:00

26 lines
701 B
JavaScript

var React = require('react')
module.exports = React.createClass({
getInitialState: function () {
return { lib: false }
},
componentDidMount: function () {
require.ensure(['react-markdown'], _ => {
if (this.isMounted()) this.setState({ MarkdownLib: require('react-markdown') })
})
},
renderIfApplicable: function () {
if (this.props.source) {
if (this.state.MarkdownLib) {
var MarkdownLib = this.state.MarkdownLib
return <MarkdownLib source={this.props.source} skipHtml={true} />
} else {
return <p>{this.props.source}</p>
}
} else return <p>...</p>
},
render: function () {
return this.renderIfApplicable()
}
})