mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Break up require/import statements in strings (#18222)
This commit is contained in:
committed by
GitHub
parent
23cd5b5bd5
commit
48662eadde
+12
-4
@@ -2937,11 +2937,15 @@ export function warnIfNotScopedWithMatchingAct(fiber: Fiber): void {
|
||||
"It looks like you're using the wrong act() around your test interactions.\n" +
|
||||
'Be sure to use the matching version of act() corresponding to your renderer:\n\n' +
|
||||
'// for react-dom:\n' +
|
||||
"import {act} from 'react-dom/test-utils';\n" +
|
||||
// Break up imports to avoid accidentally parsing them as dependencies.
|
||||
'import {act} fr' +
|
||||
"om 'react-dom/test-utils';\n" +
|
||||
'// ...\n' +
|
||||
'act(() => ...);\n\n' +
|
||||
'// for react-test-renderer:\n' +
|
||||
"import TestRenderer from 'react-test-renderer';\n" +
|
||||
// Break up imports to avoid accidentally parsing them as dependencies.
|
||||
'import TestRenderer fr' +
|
||||
"om react-test-renderer';\n" +
|
||||
'const {act} = TestRenderer;\n' +
|
||||
'// ...\n' +
|
||||
'act(() => ...);' +
|
||||
@@ -3027,7 +3031,9 @@ export function warnIfUnmockedScheduler(fiber: Fiber) {
|
||||
'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
|
||||
'to guarantee consistent behaviour across tests and browsers. ' +
|
||||
'For example, with jest: \n' +
|
||||
"jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" +
|
||||
// Break up requires to avoid accidentally parsing them as dependencies.
|
||||
"jest.mock('scheduler', () => require" +
|
||||
"('scheduler/unstable_mock'));\n\n" +
|
||||
'For more info, visit https://fb.me/react-mock-scheduler',
|
||||
);
|
||||
} else if (warnAboutUnmockedScheduler === true) {
|
||||
@@ -3036,7 +3042,9 @@ export function warnIfUnmockedScheduler(fiber: Fiber) {
|
||||
'Starting from React v17, the "scheduler" module will need to be mocked ' +
|
||||
'to guarantee consistent behaviour across tests and browsers. ' +
|
||||
'For example, with jest: \n' +
|
||||
"jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" +
|
||||
// Break up requires to avoid accidentally parsing them as dependencies.
|
||||
"jest.mock('scheduler', () => require" +
|
||||
"('scheduler/unstable_mock'));\n\n" +
|
||||
'For more info, visit https://fb.me/react-mock-scheduler',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,9 @@ export function initializeLazyComponentType(
|
||||
console.error(
|
||||
'lazy: Expected the result of a dynamic import() call. ' +
|
||||
'Instead received: %s\n\nYour code should look like: \n ' +
|
||||
"const MyComponent = lazy(() => import('./MyComponent'))",
|
||||
// Break up imports to avoid accidentally parsing them as dependencies.
|
||||
'const MyComponent = lazy(() => imp' +
|
||||
"ort('./MyComponent'))",
|
||||
moduleObject,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user