2015-11-20 20:21:54 +01:00
|
|
|
var React = require('react')
|
|
|
|
|
|
|
|
module.exports = React.createClass({
|
2015-11-22 00:10:46 +01:00
|
|
|
getInitialState: function(){
|
|
|
|
return { lib: false }
|
|
|
|
},
|
|
|
|
componentDidMount: function(){
|
|
|
|
require.ensure(['react-markdown'],_ => {
|
|
|
|
if(this.isMounted()) this.setState({ MarkdownLib: require('react-markdown') })
|
|
|
|
})
|
|
|
|
},
|
2015-11-20 20:21:54 +01:00
|
|
|
renderIfApplicable: function(){
|
2015-11-22 00:10:46 +01:00
|
|
|
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>
|
2015-11-20 20:21:54 +01:00
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
return this.renderIfApplicable()
|
|
|
|
}
|
|
|
|
})
|