diff --git a/src/components/Widgets/DateControl.js b/src/components/Widgets/DateControl.js
index b0170ee7..edd918f2 100644
--- a/src/components/Widgets/DateControl.js
+++ b/src/components/Widgets/DateControl.js
@@ -2,6 +2,12 @@ import React, { PropTypes } from 'react';
import DateTime from 'react-datetime';
export default class DateControl extends React.Component {
+ componentDidMount() {
+ if (!this.props.value) {
+ this.props.onChange(new Date());
+ }
+ }
+
handleChange = (datetime) => {
this.props.onChange(datetime);
};
@@ -9,7 +15,7 @@ export default class DateControl extends React.Component {
render() {
return ();
}
@@ -17,5 +23,5 @@ export default class DateControl extends React.Component {
DateControl.propTypes = {
onChange: PropTypes.func.isRequired,
- value: PropTypes.object,
+ value: PropTypes.object, // eslint-disable-line
};
diff --git a/src/components/Widgets/DateTimeControl.js b/src/components/Widgets/DateTimeControl.js
index 290819b4..7a690f9c 100644
--- a/src/components/Widgets/DateTimeControl.js
+++ b/src/components/Widgets/DateTimeControl.js
@@ -2,16 +2,22 @@ import React, { PropTypes } from 'react';
import DateTime from 'react-datetime';
export default class DateTimeControl extends React.Component {
- handleChange = datetime => {
+ componentDidMount() {
+ if (!this.props.value) {
+ this.props.onChange(new Date());
+ }
+ }
+
+ handleChange = (datetime) => {
this.props.onChange(datetime);
};
render() {
- return ;
+ return ;
}
}
DateTimeControl.propTypes = {
onChange: PropTypes.func.isRequired,
- value: PropTypes.object,
+ value: PropTypes.object, // eslint-disable-line
};