Created
June 14, 2018 11:58
-
-
Save OpakAlex/3da528ab8968f09009130d882f91a6a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 from 'react'; | |
import Editor from 'jsoneditor'; | |
import 'jsoneditor/dist/jsoneditor.css'; | |
export default class JSONEditor extends React.Component { | |
componentDidMount() { | |
const options = { | |
mode: 'tree', | |
modes: ['code', 'text', 'tree'], | |
onChange: () => { | |
this.props.onChange(this.editor.get()) | |
} | |
} | |
this.editor = new Editor(this.ref, options) | |
this.editor.set(this.props.json || {}) | |
} | |
render() { | |
const {className} = this.props | |
return ( | |
<div ref={ref => this.ref = ref} className={className}> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment