From 808b4e7d5787e4ad880c6999c09e07e2eef5387d Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Mon, 22 Jan 2024 20:01:49 -0500 Subject: [PATCH] Use react@17 for useSyncExternalStore shim tests --- packages/use-sync-external-store/package.json | 4 +++ .../useSyncExternalStoreShared-test.js | 8 +++++- yarn.lock | 25 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/use-sync-external-store/package.json b/packages/use-sync-external-store/package.json index b79c3501c05f4..58f190549af87 100644 --- a/packages/use-sync-external-store/package.json +++ b/packages/use-sync-external-store/package.json @@ -20,5 +20,9 @@ "license": "MIT", "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + }, + "devDependencies": { + "react-17": "npm:react@^17", + "react-dom-17": "npm:react-dom@^17" } } diff --git a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js index 1488a8aa3de6c..2727bd1f508b4 100644 --- a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js +++ b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js @@ -42,9 +42,13 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => { // eslint-disable-next-line no-unused-vars useSyncExternalStore: __, ...otherExports - } = jest.requireActual('react'); + } = jest.requireActual('react-17/umd/react.development.js'); return otherExports; }); + + jest.mock('react-dom', () => + jest.requireActual('react-dom-17/umd/react-dom.development.js'), + ); } React = require('react'); @@ -594,6 +598,8 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => { ); }).toErrorDev( 'The result of getSnapshot should be cached to avoid an infinite loop', + // Stacks don't work when we're using the npm package + {withoutStack: gate(flags => flags.enableUseSyncExternalStoreShim)}, ); }); diff --git a/yarn.lock b/yarn.lock index 3af220877f0e1..8f0c563e18db9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12838,6 +12838,14 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.8: prop-types "^15.6.2" scheduler "^0.13.0" +"react-17@npm:react@^17": + version "17.0.2" + resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037" + integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA== + dependencies: + loose-envify "^1.1.0" + object-assign "^4.1.1" + "react-dom-15@npm:react-dom@^15": version "15.6.2" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.2.tgz#41cfadf693b757faf2708443a1d1fd5a02bef730" @@ -12858,6 +12866,15 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.8: prop-types "^15.6.2" scheduler "^0.13.0" +"react-dom-17@npm:react-dom@^17": + version "17.0.2" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23" + integrity sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA== + dependencies: + loose-envify "^1.1.0" + object-assign "^4.1.1" + scheduler "^0.20.2" + react-is@^16.8.1, react-is@^17.0.1, "react-is@npm:react-is": version "17.0.2" resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" @@ -13524,6 +13541,14 @@ scheduler@^0.13.0: loose-envify "^1.1.0" object-assign "^4.1.1" +scheduler@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91" + integrity sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ== + dependencies: + loose-envify "^1.1.0" + object-assign "^4.1.1" + schema-utils@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770"