diff options
author | afc163 <afc163@gmail.com> | 2017-02-20 16:31:54 +0800 |
---|---|---|
committer | afc163 <afc163@gmail.com> | 2017-02-20 16:31:54 +0800 |
commit | 71c3a19635d989f1ed99119bf230856d9faeef21 (patch) | |
tree | a27a828296830ecfdf709739d0cbc6e17357dde8 /examples/open.js | |
parent | aa6d9b9f0867e1697a457c69e6df2bf8d0916e0a (diff) | |
download | time-picker-71c3a19635d989f1ed99119bf230856d9faeef21.tar.gz time-picker-71c3a19635d989f1ed99119bf230856d9faeef21.tar.zst time-picker-71c3a19635d989f1ed99119bf230856d9faeef21.zip |
Fix controlled open
Diffstat (limited to 'examples/open.js')
-rw-r--r-- | examples/open.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/open.js b/examples/open.js new file mode 100644 index 0000000..5a0d1ed --- /dev/null +++ b/examples/open.js | |||
@@ -0,0 +1,36 @@ | |||
1 | /* eslint no-console:0 */ | ||
2 | |||
3 | import 'rc-time-picker/assets/index.less'; | ||
4 | |||
5 | import React from 'react'; | ||
6 | import ReactDom from 'react-dom'; | ||
7 | import TimePicker from 'rc-time-picker'; | ||
8 | |||
9 | const App = React.createClass({ | ||
10 | getInitialState() { | ||
11 | return { | ||
12 | open: false, | ||
13 | }; | ||
14 | }, | ||
15 | toggleOpen() { | ||
16 | this.setState({ | ||
17 | open: !this.state.open, | ||
18 | }); | ||
19 | }, | ||
20 | setOpen({ open }) { | ||
21 | this.setState({ open }); | ||
22 | }, | ||
23 | render() { | ||
24 | return ( | ||
25 | <div> | ||
26 | <button onClick={this.toggleOpen}>Toggle open</button> | ||
27 | <TimePicker open={this.state.open} onOpen={this.setOpen} onClose={this.setOpen} /> | ||
28 | </div> | ||
29 | ); | ||
30 | }, | ||
31 | }); | ||
32 | |||
33 | ReactDom.render( | ||
34 | <App />, | ||
35 | document.getElementById('__react-content') | ||
36 | ); | ||