Skip to content

Instantly share code, notes, and snippets.

@icyJoseph
Last active September 12, 2018 16:07
Show Gist options
  • Save icyJoseph/4b4f7f549e8abd768884e2a20e0f8b1c to your computer and use it in GitHub Desktop.
Save icyJoseph/4b4f7f549e8abd768884e2a20e0f8b1c to your computer and use it in GitHub Desktop.
An example of using the ReactDOM's createPortal method.
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