We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b33e9f1 commit b2347a9Copy full SHA for b2347a9
src/components/Select2.js
@@ -52,8 +52,14 @@ export default class Select2 extends Component {
52
}
53
54
componentWillReceiveProps(nextProps) {
55
- if (this.el && nextProps.value !== this.props.value) {
56
- this.setValue(nextProps.value);
+ if (this.el) {
+ 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);
63
64
65
0 commit comments