Last active
September 12, 2018 16:07
-
-
Save icyJoseph/4b4f7f549e8abd768884e2a20e0f8b1c to your computer and use it in GitHub Desktop.
An example of using the ReactDOM's createPortal method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
export default ({ children, closeCallback }) => { | |
const composed = ( | |
<div className="Modal-container"> | |
<div className="Modal-content"> | |
{children} | |
<button onClick={closeCallback}> Close Basic Modal </button> | |
</div> | |
</div> | |
); | |
return ReactDOM.createPortal(composed, document.body); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment