The code,
import React, { Component } from 'react';
import './App.css';
import Input from "./Input";
import Output from "./Output";
import marked from 'marked';
class App extends Component {
constructor(props){
super(props);
this.state = {
input:`# Welcome to my React Markdown Previewer!
## This is a sub-heading...
### And here's some other cool stuff:`
,
output: ""
}
this.handleChange = this.handleChange.bind(this);
}
handleChange(event){
let output = marked(this.state.input);
this.setState({
input:event.target.value,
output
})
}
componentDidMount(){
this.setState({
output: marked(this.state.input)
})
}
render() {
return (
<div className="App">
<header>
<h1>Markdown previewer</h1>
</header>
<Input content={this.state.input}
action = {this.handleChange}
id="editor" />
<Output id="preview"
content={this.state.output}/>
</div>
);
}
}
export default App;
The error, ReferenceError: marked is not defined