useConfirm
calls deprecated ReactDOM.render
, triggering warning in React 18
#2990
Labels
useConfirm
calls deprecated ReactDOM.render
, triggering warning in React 18
#2990
useConfirm
usesReactDOM.render
to inject the confirmation dialog into the HTML.react/src/Dialog/ConfirmationDialog.tsx
Lines 161 to 168 in 72f0ec6
This triggers a warning in the console when in development mode:
While the warning states that the whole app will behave like it's running React 17, this isn't really the case - only the dialog will. This is because the call to
render
creates a whole new React app instance which only contains the dialog. However, this still isn't great and we definitely should resolve this.The obvious solution is to just use
createRoot
instead, but it seems like there must be a more elegant alternative here than to create an entirely new React application. What if we could come up with a way to extract thePortal
component into ausePortal
hook, allowing rendering arbitary JSX into the default portal from any hook? Something like this:I'm not sure if this is actually technically possible though - maybe I'll try and come up with a POC this week.
The text was updated successfully, but these errors were encountered: