I am having trouble with the markdown challenge. Please excuse that it looks like crap. I am trying to get the nuts and bolts working first then try and beautify it. To be honest, i have no idea what to do with the markdown translation, i just googled it and have been trying to make it fit in my preview section. I believe it is partway working, because the breaks are being translated and they wouldnt be if it wasnt working at all (i believe).
any help would be appreciated
Rob
const defaultText = `#Lorem
##lorem
###lorem
1. helo
2. world
3.
4.
5.
6.
7
8
9
10
11
12
`
class TextArea extends React.Component {
constructor(props){
super(props);
this.state = {
message: defaultText
}
this.handleChange = this.handleChange.bind(this);
}
handleChange(event){
this.setState({
message: event.target.value
})
}
render(){
return (
<div>
<h1>Markdown Editor</h1>
<textarea id='editor' value={this.state.message} onChange={this.handleChange} cols='75' rows='10' />
<Preview message={this.state.message} />
</div>
)
}
}
marked.setOptions ({
renderer: new marked.Renderer(),
breaks: true
});
class Preview extends React.Component {
constructor(props){
super(props)
}
render (){
return (
<div>
<div id='preview' dangerouslySetInnerHTML={{__html: marked(this.props.message)}} />
</div>
)
}
}
ReactDOM.render(<TextArea/>,document.getElementById('root'));