Skip to content

Commit 8d11e76

Browse files
committed
updates initialState so that it take props into account
1 parent ee5b914 commit 8d11e76

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/DateTimeField.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ DateTimeField = React.createClass({
3030
left: -9999,
3131
'z-index': '9999 !important'
3232
},
33-
viewDate: moment().startOf("month"),
34-
selectedDate: moment(),
35-
inputValue: moment().format(this.props.inputFormat)
33+
viewDate: moment(this.props.dateTime, this.props.format).startOf("month"),
34+
selectedDate: moment(this.props.dateTime, this.props.format),
35+
inputValue: moment(this.props.dateTime, this.props.format).format(this.props.inputFormat)
3636
};
3737
},
3838
componentWillReceiveProps: function(nextProps) {

src/coffee/DateTimeField.jsx.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ DateTimeField = React.createClass(
2626
position: 'absolute'
2727
left: -9999
2828
'z-index': '9999 !important'
29-
viewDate: moment().startOf("month")
30-
selectedDate: moment()
31-
inputValue: moment().format(@props.inputFormat)
29+
viewDate: moment(@props.dateTime, @props.format).startOf("month")
30+
selectedDate: moment(@props.dateTime, @props.format)
31+
inputValue: moment(@props.dateTime, @props.format).format(@props.inputFormat)
3232

3333
componentWillReceiveProps: (nextProps) ->
3434
@setState

0 commit comments

Comments
 (0)