From c22a8e2a0d8218ba720193f5fd95d28f010126aa Mon Sep 17 00:00:00 2001 From: Michael Fix Date: Sat, 18 Aug 2018 14:15:14 -0700 Subject: [PATCH] Remove gDSFP in Carbon (#477) * remove gDSFP in Carbon * add comment --- components/Carbon.js | 8 +------- components/Editor.js | 2 ++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/components/Carbon.js b/components/Carbon.js index 2b08dfa..cd31b3f 100644 --- a/components/Carbon.js +++ b/components/Carbon.js @@ -28,7 +28,7 @@ class Carbon extends PureComponent { super(props) this.state = { - language: props.config.language + ...handleLanguageChange(this.props.children, this.props) } this.handleTitleBarChange = this.handleTitleBarChange.bind(this) @@ -38,8 +38,6 @@ class Carbon extends PureComponent { } componentDidMount() { - this.setState(handleLanguageChange(this.props.children, this.props)) - const ro = new ResizeObserver(entries => { const cr = entries[0].contentRect this.props.onAspectRatioChange(cr.width / cr.height) @@ -47,10 +45,6 @@ class Carbon extends PureComponent { ro.observe(this.exportContainerNode) } - static getDerivedStateFromProps(newProps) { - return handleLanguageChange(newProps.children, newProps) || null - } - codeUpdated(newCode) { this.handleLanguageChange(newCode, this.props) this.props.updateCode(newCode) diff --git a/components/Editor.js b/components/Editor.js index a3e2ff0..279876c 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -311,7 +311,9 @@ class Editor extends React.Component { isOver={isOver || canDrop} title={`Drop your file here to import ${isOver ? '✋' : '✊'}`} > + {/*key ensures Carbon's internal language state is updated when it's changed by Dropdown*/}