Created
February 1, 2019 06:18
-
-
Save muhrusdi/08b3f32bf87b57e1c79d42785fbad160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect} from 'react' | |
import { UnControlled as CodeMirror } from 'react-codemirror2' | |
// import * as cm from "codemirror" | |
import 'codemirror/lib/codemirror.css' | |
import 'codemirror/theme/neo.css' | |
if (typeof navigator !== `undefined`) { | |
require('codemirror/mode/markdown/markdown') | |
require('codemirror/mode/javascript/javascript') | |
require('codemirror/mode/jsx/jsx') | |
require('codemirror/mode/css/css') | |
require('codemirror/addon/edit/matchbrackets') | |
require('codemirror/addon/edit/closetag') | |
require('codemirror/addon/fold/xml-fold') | |
} | |
export default ({ value }) => { | |
const [isMount, setMount] = useState(false) | |
useEffect(() => setMount(true), []) | |
return ( | |
isMount ? <CodeMirror | |
value={value} | |
options={{ | |
mode: 'jsx', | |
theme: 'neo', | |
lineNumbers: false, | |
readOnly: true, | |
showCursorWhenSelecting: false, | |
cursorHeight: 0, | |
}} | |
/> : null | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment