React - Markdown Online

Markdown Basic Syntax Online

class MarkdownEditor extends React.Component {
  constructor(props) {
    super(props);
    this.md = new remarkable.Remarkable();
    this.handleChange = this.handleChange.bind(this);
    this.state = { value: "Hello, **world**!\n* h1\n* h2\n* h3" };
  }

  handleChange(e) {
    this.setState({ value: e.target.value });
  }

  getRawMarkup() {
    return { __html: this.md.render(this.state.value) };
  }

  render() {
    return (
      <div className="MarkdownEditor">
        <h3>Input</h3>
        <label htmlFor="markdown-content">
          Enter some markdown
        </label>
        <br/>
        <textarea
          id="markdown-content"
          onChange={this.handleChange}
          defaultValue={this.state.value}
        />
        <h3>Output</h3>
        <div
          className="content"
          dangerouslySetInnerHTML={this.getRawMarkup()}
        />
      </div>
    );
  }
}

ReactDOM.render(
  <MarkdownEditor />,
  document.getElementById('markdown-example')
);