forked from rajeshpillai/youtube-react-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwithModal.js
More file actions
42 lines (34 loc) · 1.02 KB
/
withModal.js
File metadata and controls
42 lines (34 loc) · 1.02 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
import React from 'react';
import Modal from '../Modal/Modal'; // last episode.
const withModal = (WrappedComponent) => {
class _WithModal extends React.Component {
state = {
isOpen: false
}
onShow = (e) => {
console.log("DIV CLICKED");
//if (e.target.nodeName.toLowerCase() === "button") return;
this.setState({
isOpen: true
});
}
onClose = (e) => {
this.setState({
isOpen: false
});
}
render () {
return (
<div onClick={(e) => { this.onShow(e)}}>
<WrappedComponent {...this.props} />
<Modal show={this.state.isOpen} onClose={this.onClose}>
<WrappedComponent {...this.props} />
</Modal>
</div>
);
}
}
_WithModal.displayName = "WithModal";
return _WithModal;
}
export default withModal;