I understand that it's probably a bad idea to ReactDOM.render()
into document.body
. But are there any issues with using ReactDOM.createPortal()
with document.body
?
Tried looking for examples of React going bonkers when you render into body so I could test it out with createPortal but I wasn't able to find any.
To put things into context, here's a sample usage I'm speaking about:
import React from 'react';
import ReactDOM from 'react-dom';
export default class Modal extends React.Component {
render() {
return ReactDOM.createPortal(
<div className='modalContainer'>
<div className='modalBox'>
{this.props.children}
</div>
</div>,
document.body
);
}
}
Haven't run into any issues with this pattern but I'd like to know if there are consequences as I start adding more libraries.