]> git.immae.eu Git - github/fretlink/time-picker.git/blame - examples/value-and-defaultValue.js
Merge pull request #71 from ZaiusInc/focus-on-open
[github/fretlink/time-picker.git] / examples / value-and-defaultValue.js
CommitLineData
d3606149 1/* eslint no-console:0 */
2
3import 'rc-time-picker/assets/index.less';
4
5import React from 'react';
6import ReactDom from 'react-dom';
4984ed85 7import moment from 'moment';
d3606149 8import TimePicker from 'rc-time-picker';
d3606149 9
3ab3a128 10class App extends React.Component {
11 state = {
12 value: moment(),
13 };
14 handleValueChange = (value) => {
4984ed85 15 console.log(value && value.format('HH:mm:ss'));
d3606149 16 this.setState({ value });
3ab3a128 17 }
18 clear = () => {
6fc4e0e8 19 this.setState({
20 value: undefined,
21 });
3ab3a128 22 }
d3606149 23 render() {
24 return (
25 <div>
4984ed85 26 <TimePicker
27 defaultValue={this.state.value}
28 onChange={this.handleValueChange}
29 />
30 <TimePicker
31 value={this.state.value}
32 onChange={this.handleValueChange}
33 />
6fc4e0e8 34 <button onClick={this.clear}>clear</button>
d3606149 35 </div>
36 );
3ab3a128 37 }
38}
d3606149 39
40ReactDom.render(
41 <App />,
42 document.getElementById('__react-content')
43);