From b8202ba748d6a579313c6e948717c428cfe19c1a Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Mon, 24 Jun 2019 10:26:56 +0100 Subject: [PATCH] a better message, consistent with the state update one. --- .../react-dom/src/__tests__/ReactDOMHooks-test.js | 8 ++++---- .../react-reconciler/src/ReactFiberWorkLoop.js | 2 +- .../src/__tests__/ReactHooks-test.internal.js | 2 +- .../ReactHooksWithNoopRenderer-test.internal.js | 14 ++++++-------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMHooks-test.js b/packages/react-dom/src/__tests__/ReactDOMHooks-test.js index 1af896f1631e2..ec23c88fa981f 100644 --- a/packages/react-dom/src/__tests__/ReactDOMHooks-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMHooks-test.js @@ -74,10 +74,10 @@ describe('ReactDOMHooks', () => { expect(container2.textContent).toBe('4'); expect(container3.textContent).toBe('6'); }).toWarnDev([ - 'Your test just caused an effect from Example1', - 'Your test just caused an effect from Example2', - 'Your test just caused an effect from Example1', - 'Your test just caused an effect from Example2', + 'An update to Example1 ran an effect', + 'An update to Example2 ran an effect', + 'An update to Example1 ran an effect', + 'An update to Example2 ran an effect', ]); }); diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index d2a60a636fad1..ebf98cf617b41 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -2434,7 +2434,7 @@ export function warnIfNotCurrentlyActingEffectsInDEV(fiber: Fiber): void { if (ReactCurrentActingRendererSigil.current !== ReactActingRendererSigil) { warningWithoutStack( false, - 'Your test just caused an effect from %s, but was not wrapped in act(...).\n\n' + + 'An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + diff --git a/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js b/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js index 922aa8c89110a..ea6e3103edfe1 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js @@ -1800,7 +1800,7 @@ describe('ReactHooks', () => { globalListener(); globalListener(); }).toWarnDev([ - 'Your test just caused an effect from C', + 'An update to C ran an effect', 'An update to C inside a test was not wrapped in act', 'An update to C inside a test was not wrapped in act', // Note: should *not* warn about updates on unmounted component. diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js index d55781e0af2fe..db3ee1ecc2d37 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js @@ -885,14 +885,13 @@ describe('ReactHooksWithNoopRenderer', () => { // we explicitly wait for missing act() warnings here since // it's a lot harder to simulate this condition inside an act scope - // todo - is this ok? expect(() => { ReactNoop.render(, () => Scheduler.yieldValue('Sync effect'), ); expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']); expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]); - }).toWarnDev(['Your test just caused an effect from Counter']); + }).toWarnDev(['An update to Counter ran an effect']); // A discrete event forces the passive effect to be flushed -- // updateCount(1) happens first, so 2 wins. @@ -907,8 +906,8 @@ describe('ReactHooksWithNoopRenderer', () => { expect(() => { expect(Scheduler).toFlushAndYield(['Count: 2']); }).toWarnDev([ - 'Your test just caused an effect from Counter', - 'Your test just caused an effect from Counter', + 'An update to Counter ran an effect', + 'An update to Counter ran an effect', ]); expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]); @@ -943,7 +942,6 @@ describe('ReactHooksWithNoopRenderer', () => { const tracingEvent = {id: 0, name: 'hello', timestamp: 0}; // we explicitly wait for missing act() warnings here since // it's a lot harder to simulate this condition inside an act scope - // todo - is this ok? expect(() => { SchedulerTracing.unstable_trace( tracingEvent.name, @@ -956,7 +954,7 @@ describe('ReactHooksWithNoopRenderer', () => { ); expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']); expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]); - }).toWarnDev(['Your test just caused an effect from Counter']); + }).toWarnDev(['An update to Counter ran an effect']); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(0); @@ -973,8 +971,8 @@ describe('ReactHooksWithNoopRenderer', () => { expect(() => { expect(Scheduler).toFlushAndYield(['Count: 2']); }).toWarnDev([ - 'Your test just caused an effect from Counter', - 'Your test just caused an effect from Counter', + 'An update to Counter ran an effect', + 'An update to Counter ran an effect', ]); expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]);