diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index d5aac06fdf157..a9a5354544ddc 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -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', ); } diff --git a/packages/shared/ReactLazyComponent.js b/packages/shared/ReactLazyComponent.js index 24b360a1e57a1..4557ac0d17e75 100644 --- a/packages/shared/ReactLazyComponent.js +++ b/packages/shared/ReactLazyComponent.js @@ -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, ); }