Remove gDSFP in Carbon (#477)

* remove gDSFP in Carbon

* add comment
main
Michael Fix 6 years ago committed by GitHub
parent a0b1c29727
commit c22a8e2a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,7 +28,7 @@ class Carbon extends PureComponent {
super(props) super(props)
this.state = { this.state = {
language: props.config.language ...handleLanguageChange(this.props.children, this.props)
} }
this.handleTitleBarChange = this.handleTitleBarChange.bind(this) this.handleTitleBarChange = this.handleTitleBarChange.bind(this)
@ -38,8 +38,6 @@ class Carbon extends PureComponent {
} }
componentDidMount() { componentDidMount() {
this.setState(handleLanguageChange(this.props.children, this.props))
const ro = new ResizeObserver(entries => { const ro = new ResizeObserver(entries => {
const cr = entries[0].contentRect const cr = entries[0].contentRect
this.props.onAspectRatioChange(cr.width / cr.height) this.props.onAspectRatioChange(cr.width / cr.height)
@ -47,10 +45,6 @@ class Carbon extends PureComponent {
ro.observe(this.exportContainerNode) ro.observe(this.exportContainerNode)
} }
static getDerivedStateFromProps(newProps) {
return handleLanguageChange(newProps.children, newProps) || null
}
codeUpdated(newCode) { codeUpdated(newCode) {
this.handleLanguageChange(newCode, this.props) this.handleLanguageChange(newCode, this.props)
this.props.updateCode(newCode) this.props.updateCode(newCode)

@ -311,7 +311,9 @@ class Editor extends React.Component {
isOver={isOver || canDrop} isOver={isOver || canDrop}
title={`Drop your file here to import ${isOver ? '✋' : '✊'}`} title={`Drop your file here to import ${isOver ? '✋' : '✊'}`}
> >
{/*key ensures Carbon's internal language state is updated when it's changed by Dropdown*/}
<Carbon <Carbon
key={this.state.language}
config={this.state} config={this.state}
updateCode={this.updateCode} updateCode={this.updateCode}
onAspectRatioChange={this.updateAspectRatio} onAspectRatioChange={this.updateAspectRatio}

Loading…
Cancel
Save