Skip to content

Commit

Permalink
solution for Portals excersize
Browse files Browse the repository at this point in the history
  • Loading branch information
souvikbasu committed Mar 31, 2018
1 parent 9e1e932 commit e02ee65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
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

0 comments on commit e02ee65

Please sign in to comment.