File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
exercises/src/portals/01-using-modals/src Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const App = (props) => {
88 < div >
99 < Header />
1010 < Main />
11+ < div id = "modal" > </ div >
1112 </ div >
1213 ) ;
1314}
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import ReactDOM from 'react-dom' ;
23
34class Modal extends React . Component {
45
@@ -7,16 +8,21 @@ class Modal extends React.Component {
78 return null ;
89 }
910
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+ } ;
1518
1619
17- return < div style = { modalStyle } >
20+ return ReactDOM . createPortal (
21+ < div style = { modalStyle } >
1822 { this . props . children }
19- </ div > ;
23+ </ div > ,
24+ document . getElementById ( 'modal' ) ,
25+ ) ;
2026 }
2127}
2228
You can’t perform that action at this time.
0 commit comments