mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Set date to initial value when reset (#10412)
This commit is contained in:
1 parent
9166cf9b8d
commit
64287af8d1
1 file changed
+5
-5
@@ -1,5 +1,6 @@
|
||||
const React = window.React;
|
||||
|
||||
const startDate = new Date();
|
||||
/**
|
||||
* This test case was originally provided by @richsoni,
|
||||
* https://github.com/facebook/react/issues/8116
|
||||
@@ -7,7 +8,7 @@ const React = window.React;
|
||||
class SwitchDateTestCase extends React.Component {
|
||||
state = {
|
||||
fullDate: false,
|
||||
date: new Date(),
|
||||
date: startDate,
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -50,10 +51,9 @@ class SwitchDateTestCase extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
onInputChange = event => {
|
||||
this.setState({
|
||||
date: new Date(Date.parse(event.target.value)),
|
||||
});
|
||||
onInputChange = ({target: {value}}) => {
|
||||
const date = value ? new Date(Date.parse(value)) : startDate;
|
||||
this.setState({date});
|
||||
};
|
||||
|
||||
updateFullDate = () => {
|
||||
|
||||
Reference in new issue
Block a user