File tree 2 files changed +14
-7
lines changed
exercises/src/portals/01-using-modals/src
2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const App = (props) => {
8
8
< div >
9
9
< Header />
10
10
< Main />
11
+ < div id = "modal" > </ div >
11
12
</ div >
12
13
) ;
13
14
}
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import ReactDOM from 'react-dom' ;
2
3
3
4
class Modal extends React . Component {
4
5
@@ -7,16 +8,21 @@ class Modal extends React.Component {
7
8
return null ;
8
9
}
9
10
10
- const modalStyle = {
11
- background : 'transparent' ,
12
- width : '100%' ,
13
- textAlign : 'center'
14
- } ;
11
+ const modalStyle = {
12
+ background : 'transparent' ,
13
+ position : 'absolute' ,
14
+ top : 200 ,
15
+ width : '100%' ,
16
+ textAlign : 'center'
17
+ } ;
15
18
16
19
17
- return < div style = { modalStyle } >
20
+ return ReactDOM . createPortal (
21
+ < div style = { modalStyle } >
18
22
{ this . props . children }
19
- </ div > ;
23
+ </ div > ,
24
+ document . getElementById ( 'modal' ) ,
25
+ ) ;
20
26
}
21
27
}
22
28
You can’t perform that action at this time.
0 commit comments