Skip to content

Commit

Permalink
Add shim for react-dom/client for React 17
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Dec 5, 2024
1 parent e86d014 commit 60fd22a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const standardReact17Config = {
moduleNameMapper: {
"^react$": "react-17",
"^react-dom$": "react-dom-17",
"^react-dom/client$": "<rootDir>/../config/jest/react-dom-17-client.js",
"^react-dom/server$": "react-dom-17/server",
"^react-dom/test-utils$": "react-dom-17/test-utils",
},
Expand Down
15 changes: 15 additions & 0 deletions config/jest/react-dom-17-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Shim for React 17 react-dom/client entrypoint imported by React Testing
// Library

module.exports = {
hydrateRoot: () => {
throw new Error(
"Cannot use hydrateRoot with React 17. Ensure this uses legacy root instead"
);
},
createRoot: () => {
throw new Error(
"Cannot use createRoot with React 17. Ensure this uses legacy root instead"
);
},
};

0 comments on commit 60fd22a

Please sign in to comment.