Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3.  
  4. import style from './Modal.module.scss';
  5.  
  6. /*
  7. Modal asks parent to unmount modal by setting modal prop value to false. This happens when the
  8. user clicks outside the modal.
  9. */
  10.  
  11. function Modal (props) {
  12.  
  13. if(props.modal) {
  14. return ReactDOM.createPortal(
  15. <div className={style.Modal} role="complementary" onClick={(e) => {e.stopPropagation(); props.openModal(false); }} >
  16. <div className={style.content} onClick={(e) => e.stopPropagation()}>
  17. {props.children}
  18. </div>
  19.  
  20. </div>, document.body
  21. );
  22. } else {
  23. return null;
  24. }
  25.  
  26.  
  27.  
  28. }
  29. export default Modal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement