check onChange exists before call it

This commit is contained in:
Comus Leong 2017-01-07 00:12:11 +08:00
parent 171270376b
commit 12a1ad180a

View file

@ -12,7 +12,7 @@ export class Field extends React.Component {
triggerUpdate() {
// Trigger an onChange on inital load, to support browser prefilled values.
const { onChange } = this.props;
if (this.input && this.input.value) {
if (this.input && this.input.value && onChange) {
onChange({ target: { value: this.input.value } });
}
}