Skip to content

Commit b2347a9

Browse files
committed
Fix update value
1 parent b33e9f1 commit b2347a9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/Select2.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ export default class Select2 extends Component {
5252
}
5353

5454
componentWillReceiveProps(nextProps) {
55-
if (this.el && nextProps.value !== this.props.value) {
56-
this.setValue(nextProps.value);
55+
if (this.el) {
56+
let value = nextProps.value;
57+
const { defaultValue } = this.props;
58+
const setDefaultValue = typeof defaultValue !== 'undefined' && (typeof value === 'undefined' || value === null);
59+
if (setDefaultValue) {
60+
value = defaultValue;
61+
}
62+
this.setValue(value);
5763
}
5864
}
5965

0 commit comments

Comments
 (0)