react-selectize
react-selectize copied to clipboard
Unable to modify the defaultValue after the first component mount
Hello,
i noticed that is actually hard to update the default value due to subsequent calls.
Example: i create the SimpleSelect component with a defaultValue={label: "a", value: 1}
Now, due to my internal refresh api call, the component is updated by passing new defaultValue ={label: "b", value: 2}
This is not propagated to component, i think because of the creation of the component:
function SimpleSelect(props){ var ref$; SimpleSelect.superclass.call(this, props); this.state = { highlightedUid: undefined, open: false, scrollLock: false, search: "", value: (ref$ = this.props) != null ? ref$.defaultValue : void 8 }; }
mainly due to value: (ref$ = this.props) != null ? ref$.defaultValue : void 8
It is possible to update the defaultValue to the component?
I think defaultValue is not something that can be dynamically changed by design. If there is an event that changes the value of the input you should change the value and not the defaultValue (or maybe even defaultValue is not the right choice for your implementation, since it should be static, and you should implement "default" value on your code).