Skip to content

Instantly share code, notes, and snippets.

@g-a-v-i-n
Created January 24, 2020 23:05
Show Gist options
  • Save g-a-v-i-n/eb22bc27ebe559303be00d3e8992c819 to your computer and use it in GitHub Desktop.
Save g-a-v-i-n/eb22bc27ebe559303be00d3e8992c819 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import {Controlled as CodeMirror} from 'react-codemirror2'
import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/material.css';
import 'codemirror/mode/markdown/markdown'
class App extends Component {
constructor(props) {
super(props);
// Don't call this.setState() here!
this.state = {
value: '# Hello'
};
}
render() {
const options = {
mode: 'markdown',
theme: 'tlon',
lineNumbers: false,
lineWrapping: true,
scrollbarStyle: null,
cursorHeight: 0.85,
}
return (
<div className="App">
<CodeMirror
value={this.state.value}
options={options}
onBeforeChange={(editor, data, value) => {
this.setState({value});
}}
onChange={(editor, data, value) => {
}} />
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment