forked from reactjs/react-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
62 lines (52 loc) · 1.46 KB
/
Copy pathapp.js
File metadata and controls
62 lines (52 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var React = require('react');
var ReactDOM = require('react-dom');
var Modal = require('../../lib/index');
var appElement = document.getElementById('example');
Modal.setAppElement('#example');
var App = React.createClass({
getInitialState: function() {
return { modalIsOpen: false };
},
openModal: function() {
this.setState({modalIsOpen: true});
},
closeModal: function() {
this.setState({modalIsOpen: false});
},
handleModalCloseRequest: function() {
// opportunity to validate something and keep the modal open even if it
// requested to be closed
this.setState({modalIsOpen: false});
},
handleInputChange: function() {
this.setState({foo: 'bar'});
},
render: function() {
return (
<div>
<button onClick={this.openModal}>Open Modal</button>
<Modal
closeTimeoutMS={150}
isOpen={this.state.modalIsOpen}
onRequestClose={this.handleModalCloseRequest}>
<h1>Hello</h1>
<button onClick={this.closeModal}>close</button>
<div>I am a modal</div>
<form>
<input onChange={this.handleInputChange} />
<input />
<input />
<input />
<input />
<br/>
<button>hi</button>
<button>hi</button>
<button>hi</button>
<button>hi</button>
</form>
</Modal>
</div>
);
}
});
ReactDOM.render(<App/>, appElement);