From cc6507746402757434057cc85d075c3dda069457 Mon Sep 17 00:00:00 2001 From: Jan Myler Date: Sun, 29 Jan 2017 15:23:48 +0100 Subject: [PATCH] Add onChange callback to Playground --- src/components/playground.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/playground.jsx b/src/components/playground.jsx index b393503..e6ae267 100644 --- a/src/components/playground.jsx +++ b/src/components/playground.jsx @@ -12,7 +12,8 @@ class ReactPlayground extends Component { theme: "monokai", noRender: true, context: {}, - initiallyExpanded: false + initiallyExpanded: false, + onChange: () => {} }; static propTypes = { @@ -27,7 +28,8 @@ class ReactPlayground extends Component { es6Console: PropTypes.bool, context: PropTypes.object, initiallyExpanded: PropTypes.bool, - previewComponent: PropTypes.node + previewComponent: PropTypes.node, + onChange: PropTypes.func }; state = { @@ -44,10 +46,12 @@ class ReactPlayground extends Component { }; _handleCodeChange = (code) => { + const { onChange } = this.props; + this.setState({ code, external: false - }); + }, () => onChange(code)); }; _toggleCode = () => {