Skip to content
This repository was archived by the owner on Nov 16, 2018. It is now read-only.

Commit 802bee8

Browse files
committed
Change this.state.inputFormat when this.props.inputFormat changes
1 parent a42a37a commit 802bee8

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/DateTimeField.jsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@ DateTimeField = React.createClass({
3535
}
3636
};
3737
},
38-
resolvePropsInputFormat: function() {
39-
if(this.props.inputFormat) return this.props.inputFormat;
40-
switch(this.props.mode) {
41-
case Constants.MODE_TIME:
42-
return "h:mm A";
43-
case Constants.MODE_DATE:
44-
return "MM/DD/YY";
45-
default:
46-
return "MM/DD/YY h:mm A";
47-
}
48-
},
4938
getInitialState: function() {
5039
return {
5140
showDatePicker: this.props.mode !== Constants.MODE_TIME,
@@ -71,6 +60,22 @@ DateTimeField = React.createClass({
7160
inputValue: moment(nextProps.dateTime, nextProps.format, true).format(nextProps.inputFormat)
7261
});
7362
}
63+
if (nextProps.inputFormat !== this.props.inputFormat) {
64+
return this.setState({
65+
inputFormat: nextProps.inputFormat
66+
});
67+
}
68+
},
69+
resolvePropsInputFormat: function() {
70+
if(this.props.inputFormat) return this.props.inputFormat;
71+
switch(this.props.mode) {
72+
case Constants.MODE_TIME:
73+
return "h:mm A";
74+
case Constants.MODE_DATE:
75+
return "MM/DD/YY";
76+
default:
77+
return "MM/DD/YY h:mm A";
78+
}
7479
},
7580
onChange: function(event) {
7681
var value = event.target == null ? event : event.target.value;

0 commit comments

Comments
 (0)