forked from p15670423/monkey
UI: Get derived state from props in AdvancedMultiSelect
This commit is contained in:
parent
18ceb6c279
commit
320364a7a2
|
@ -32,7 +32,6 @@ function AdvancedMultiSelectHeader(props) {
|
|||
class AdvancedMultiSelect extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
let selectedPluginNames = this.props.value.map(v => v.name);
|
||||
let allPluginNames = this.props.options.enumOptions.map(v => v.value);
|
||||
|
||||
|
@ -162,6 +161,16 @@ class AdvancedMultiSelect extends React.Component {
|
|||
this.onChange(safePluginNames);
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(props, current_state) {
|
||||
let propsPluginNames = props.value.map(v => v.name);
|
||||
if (current_state.selectedPluginNames !== propsPluginNames) {
|
||||
return {
|
||||
selectedPluginNames: propsPluginNames
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
autofocus,
|
||||
|
|
Loading…
Reference in New Issue