Skip to content

Commit

Permalink
Use React 18 createRoot API
Browse files Browse the repository at this point in the history
This breaks compatibility with React <18,
but eliminates noisy console warnings in projects that have upgraded
to React 18.
  • Loading branch information
sentience committed Aug 17, 2023
1 parent 6ab229b commit 8854b30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-ties-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kaizen/notification": major
---

Upgrade to React 18 render API
4 changes: 2 additions & 2 deletions packages/notification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"peerDependencies": {
"@kaizen/design-tokens": "^2.10.3 || ^3.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0",
"react": "^16.14.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"
"react": "^18.0.0",
"react-dom": "^18.0.0"
}
}
8 changes: 3 additions & 5 deletions packages/notification/src/ToastNotificationManager.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import ReactDOM from "react-dom"
import { createRoot } from "react-dom/client"
import { v4 } from "uuid"
import { ToastNotificationsListContainer } from "./ToastNotificationsList"
import {
Expand Down Expand Up @@ -109,13 +109,11 @@ const createToastNotificationManager = (): ToastNotificationApi => {
}

if (portal) {
// eslint-disable-next-line react/no-deprecated
ReactDOM.render(
createRoot(portal).render(
<ToastNotificationsListContainer
removeToastNotification={removeToastNotification}
registerSetNotificationsCallback={registerSetNotificationsCallback}
/>,
portal
/>
)
}

Expand Down

0 comments on commit 8854b30

Please sign in to comment.