diff --git a/.gitignore b/.gitignore index 1b6af44e..ca9d54ff 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /packages/**/node_modules /packages/**/dist /lerna-debug.log + diff --git a/docs/guide/source-code-explore.md b/docs/guide/source-code-explore.md index d276e474..c9f47b05 100644 --- a/docs/guide/source-code-explore.md +++ b/docs/guide/source-code-explore.md @@ -222,8 +222,8 @@ function getProvider(store, app, router) { // 真正的 react 在这里 function render(container, store, app, router) { - const ReactDOM = require('react-dom'); // eslint-disable-line - ReactDOM.render(React.createElement(getProvider(store, app, router)), container); + const ReactDOM = require('react-dom/client') // eslint-disable-line + ReactDOM.createRoot(container).render(React.createElement(getProvider(store, app, router))); } ``` diff --git a/package.json b/package.json index 8c90cced..1b5e6a0e 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "lerna-changelog": "^0.8.0", "lint-staged": "^7.2.2", "prettier": "^1.14.3", - "react": "^16.8.4", - "react-dom": "^16.8.4", + "react": "^18.0.0", + "react-dom": "^18.0.0", "react-testing-library": "^6.0.0", "shelljs": "^0.8.1", "umi-test": "^1.5.2" diff --git a/packages/dva/package.json b/packages/dva/package.json index 8c236259..f856e790 100644 --- a/packages/dva/package.json +++ b/packages/dva/package.json @@ -45,8 +45,8 @@ "redux": "^4.0.1" }, "peerDependencies": { - "react": "^16.8.4", - "react-dom": "^16.8.4" + "react": ">=18", + "react-dom": ">=18" }, "files": [ "dist", diff --git a/packages/dva/src/index.js b/packages/dva/src/index.js index f66af8d9..e7175671 100644 --- a/packages/dva/src/index.js +++ b/packages/dva/src/index.js @@ -99,8 +99,8 @@ function getProvider(store, app, router) { } function render(container, store, app, router) { - const ReactDOM = require('react-dom'); // eslint-disable-line - ReactDOM.render(React.createElement(getProvider(store, app, router)), container); + const ReactDOM = require('react-dom/client'); // eslint-disable-line + ReactDOM.createRoot(container).render(React.createElement(getProvider(store, app, router))); } function patchHistory(history) {