Skip to content

Commit

Permalink
Merge pull request #489 from leoendless/hotfix/codeEditor
Browse files Browse the repository at this point in the history
fix: Add props upadte logic for code editor
  • Loading branch information
leoendless authored Jun 24, 2020
2 parents 5a31e1d + 18fb0d9 commit e2a6399
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/components/Base/CodeEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ class CodeEditor extends PureComponent {
}
}

static getDerivedStateFromProps(props, state) {
const { value } = props

if (value !== state.originValue) {
return {
value: getValue(value),
originValue: value,
}
}

return null
}

handleChange = value => {
const { onChange } = this.props
this.setState({ value }, () => onChange(value))
Expand Down
11 changes: 5 additions & 6 deletions src/components/Forms/AppDeploy/AppConfig/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ export default class Services extends React.Component {
set(
formData,
'conf',
getValue(
Object.assign({}, getValueObj(this.state.valuesYaml), {
Name: formData.name || '',
Description: formData.desc || '',
})
)
getValue({
...getValueObj(this.state.valuesYaml),
Name: formData.name || '',
Description: formData.desc || '',
})
)
}

Expand Down

0 comments on commit e2a6399

Please sign in to comment.