Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercises/src/portals/01-using-modals/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const App = (props) => {
<div>
<Header />
<Main />
<div id="modal"></div>
</div>
);
}
Expand Down
20 changes: 13 additions & 7 deletions exercises/src/portals/01-using-modals/src/Modal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';

class Modal extends React.Component {

Expand All @@ -7,16 +8,21 @@ class Modal extends React.Component {
return null;
}

const modalStyle = {
background: 'transparent',
width: '100%',
textAlign: 'center'
};
const modalStyle = {
background: 'transparent',
position: 'absolute',
top: 200,
width: '100%',
textAlign: 'center'
};


return <div style={modalStyle} >
return ReactDOM.createPortal(
<div style={modalStyle} >
{this.props.children}
</div>;
</div>,
document.getElementById('modal'),
);
}
}

Expand Down