Open bsgreenb opened 4 years ago
I'm sure there are other ways to do this. At the time, I just wanted a re-usable approach.
Pretty sure it's still is the state of the art method.. not sure if that's bad or not, but it works damn well
is this still the best way? It would be great to take that pr that solves the warnings
You can just use
import { createPortal } from 'react-dom';
function MyComponent() {
return (
<div style={{ border: '2px solid black' }}>
<p>This child is placed in the parent div.</p>
{createPortal(
<p>This child is placed in the document body.</p>,
document.body
)}
</div>
);
}
See it hasn't been updated in 17 months, wondering if Gatsby has solved for this or if there's a new approach?