Skip to content

Commit a620062

Browse files
committed
Resolve breaking changes
1 parent 46494f6 commit a620062

File tree

3 files changed

+49
-37
lines changed

3 files changed

+49
-37
lines changed

packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ describe('ReactHooksWithNoopRenderer', () => {
17771777
}, [props.count]);
17781778
return <Text text={'Count: ' + count} />;
17791779
}
1780-
expect(() =>
1780+
expect(() => {
17811781
act(() => {
17821782
ReactNoop.render(<Counter count={0} />, () =>
17831783
Scheduler.unstable_yieldValue('Sync effect'),
@@ -1787,8 +1787,8 @@ describe('ReactHooksWithNoopRenderer', () => {
17871787
'Sync effect',
17881788
]);
17891789
expect(ReactNoop.getChildren()).toEqual([span('Count: (empty)')]);
1790-
}),
1791-
).toErrorDev('flushSync was called from inside a lifecycle method');
1790+
});
1791+
}).toErrorDev('flushSync was called from inside a lifecycle method');
17921792
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
17931793
});
17941794

@@ -2648,32 +2648,32 @@ describe('ReactHooksWithNoopRenderer', () => {
26482648
}
26492649

26502650
const root1 = ReactNoop.createRoot();
2651-
expect(() =>
2651+
expect(() => {
26522652
act(() => {
26532653
root1.render(<App return={17} />);
2654-
}),
2655-
).toErrorDev([
2654+
});
2655+
}).toErrorDev([
26562656
'Warning: useEffect must not return anything besides a ' +
26572657
'function, which is used for clean-up. You returned: 17',
26582658
]);
26592659

26602660
const root2 = ReactNoop.createRoot();
2661-
expect(() =>
2661+
expect(() => {
26622662
act(() => {
26632663
root2.render(<App return={null} />);
2664-
}),
2665-
).toErrorDev([
2664+
});
2665+
}).toErrorDev([
26662666
'Warning: useEffect must not return anything besides a ' +
26672667
'function, which is used for clean-up. You returned null. If your ' +
26682668
'effect does not require clean up, return undefined (or nothing).',
26692669
]);
26702670

26712671
const root3 = ReactNoop.createRoot();
2672-
expect(() =>
2672+
expect(() => {
26732673
act(() => {
26742674
root3.render(<App return={Promise.resolve()} />);
2675-
}),
2676-
).toErrorDev([
2675+
});
2676+
}).toErrorDev([
26772677
'Warning: useEffect must not return anything besides a ' +
26782678
'function, which is used for clean-up.\n\n' +
26792679
'It looks like you wrote useEffect(async () => ...) or returned a Promise.',
@@ -3052,32 +3052,32 @@ describe('ReactHooksWithNoopRenderer', () => {
30523052
}
30533053

30543054
const root1 = ReactNoop.createRoot();
3055-
expect(() =>
3055+
expect(() => {
30563056
act(() => {
30573057
root1.render(<App return={17} />);
3058-
}),
3059-
).toErrorDev([
3058+
});
3059+
}).toErrorDev([
30603060
'Warning: useInsertionEffect must not return anything besides a ' +
30613061
'function, which is used for clean-up. You returned: 17',
30623062
]);
30633063

30643064
const root2 = ReactNoop.createRoot();
3065-
expect(() =>
3065+
expect(() => {
30663066
act(() => {
30673067
root2.render(<App return={null} />);
3068-
}),
3069-
).toErrorDev([
3068+
});
3069+
}).toErrorDev([
30703070
'Warning: useInsertionEffect must not return anything besides a ' +
30713071
'function, which is used for clean-up. You returned null. If your ' +
30723072
'effect does not require clean up, return undefined (or nothing).',
30733073
]);
30743074

30753075
const root3 = ReactNoop.createRoot();
3076-
expect(() =>
3076+
expect(() => {
30773077
act(() => {
30783078
root3.render(<App return={Promise.resolve()} />);
3079-
}),
3080-
).toErrorDev([
3079+
});
3080+
}).toErrorDev([
30813081
'Warning: useInsertionEffect must not return anything besides a ' +
30823082
'function, which is used for clean-up.\n\n' +
30833083
'It looks like you wrote useInsertionEffect(async () => ...) or returned a Promise.',
@@ -3104,11 +3104,11 @@ describe('ReactHooksWithNoopRenderer', () => {
31043104
}
31053105

31063106
const root = ReactNoop.createRoot();
3107-
expect(() =>
3107+
expect(() => {
31083108
act(() => {
31093109
root.render(<App />);
3110-
}),
3111-
).toErrorDev(['Warning: useInsertionEffect must not schedule updates.']);
3110+
});
3111+
}).toErrorDev(['Warning: useInsertionEffect must not schedule updates.']);
31123112

31133113
expect(() => {
31143114
act(() => {
@@ -3359,32 +3359,32 @@ describe('ReactHooksWithNoopRenderer', () => {
33593359
}
33603360

33613361
const root1 = ReactNoop.createRoot();
3362-
expect(() =>
3362+
expect(() => {
33633363
act(() => {
33643364
root1.render(<App return={17} />);
3365-
}),
3366-
).toErrorDev([
3365+
});
3366+
}).toErrorDev([
33673367
'Warning: useLayoutEffect must not return anything besides a ' +
33683368
'function, which is used for clean-up. You returned: 17',
33693369
]);
33703370

33713371
const root2 = ReactNoop.createRoot();
3372-
expect(() =>
3372+
expect(() => {
33733373
act(() => {
33743374
root2.render(<App return={null} />);
3375-
}),
3376-
).toErrorDev([
3375+
});
3376+
}).toErrorDev([
33773377
'Warning: useLayoutEffect must not return anything besides a ' +
33783378
'function, which is used for clean-up. You returned null. If your ' +
33793379
'effect does not require clean up, return undefined (or nothing).',
33803380
]);
33813381

33823382
const root3 = ReactNoop.createRoot();
3383-
expect(() =>
3383+
expect(() => {
33843384
act(() => {
33853385
root3.render(<App return={Promise.resolve()} />);
3386-
}),
3387-
).toErrorDev([
3386+
});
3387+
}).toErrorDev([
33883388
'Warning: useLayoutEffect must not return anything besides a ' +
33893389
'function, which is used for clean-up.\n\n' +
33903390
'It looks like you wrote useLayoutEffect(async () => ...) or returned a Promise.',

packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ describe 'ReactCoffeeScriptClass', ->
131131
expect(->
132132
act ->
133133
root.render React.createElement(Foo, foo: 'foo')
134+
return
134135
).toErrorDev 'Foo: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.'
135136

136137
it 'warns if getDerivedStateFromError is not static', ->
@@ -142,6 +143,7 @@ describe 'ReactCoffeeScriptClass', ->
142143
expect(->
143144
act ->
144145
root.render React.createElement(Foo, foo: 'foo')
146+
return
145147
).toErrorDev 'Foo: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.'
146148

147149
it 'warns if getSnapshotBeforeUpdate is static', ->
@@ -153,6 +155,7 @@ describe 'ReactCoffeeScriptClass', ->
153155
expect(->
154156
act ->
155157
root.render React.createElement(Foo, foo: 'foo')
158+
return
156159
).toErrorDev 'Foo: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.'
157160

158161
it 'warns if state not initialized before static getDerivedStateFromProps', ->
@@ -169,6 +172,7 @@ describe 'ReactCoffeeScriptClass', ->
169172
expect(->
170173
act ->
171174
root.render React.createElement(Foo, foo: 'foo')
175+
return
172176
).toErrorDev (
173177
'`Foo` uses `getDerivedStateFromProps` but its initial state is ' +
174178
'undefined. This is not recommended. Instead, define the initial state by ' +

packages/react/src/__tests__/ReactES6Class-test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ describe('ReactES6Class', () => {
147147
return <div />;
148148
}
149149
}
150-
expect(() => act(() => root.render(<Foo foo="foo" />))).toErrorDev(
150+
expect(() => {
151+
act(() => root.render(<Foo foo="foo" />));
152+
}).toErrorDev(
151153
'Foo: getDerivedStateFromProps() is defined as an instance method ' +
152154
'and will be ignored. Instead, declare it as a static method.',
153155
);
@@ -162,7 +164,9 @@ describe('ReactES6Class', () => {
162164
return <div />;
163165
}
164166
}
165-
expect(() => act(() => root.render(<Foo foo="foo" />))).toErrorDev(
167+
expect(() => {
168+
act(() => root.render(<Foo foo="foo" />));
169+
}).toErrorDev(
166170
'Foo: getDerivedStateFromError() is defined as an instance method ' +
167171
'and will be ignored. Instead, declare it as a static method.',
168172
);
@@ -175,7 +179,9 @@ describe('ReactES6Class', () => {
175179
return <div />;
176180
}
177181
}
178-
expect(() => act(() => root.render(<Foo foo="foo" />))).toErrorDev(
182+
expect(() => {
183+
act(() => root.render(<Foo foo="foo" />));
184+
}).toErrorDev(
179185
'Foo: getSnapshotBeforeUpdate() is defined as a static method ' +
180186
'and will be ignored. Instead, declare it as an instance method.',
181187
);
@@ -193,7 +199,9 @@ describe('ReactES6Class', () => {
193199
return <div className={`${this.state.foo} ${this.state.bar}`} />;
194200
}
195201
}
196-
expect(() => act(() => root.render(<Foo foo="foo" />))).toErrorDev(
202+
expect(() => {
203+
act(() => root.render(<Foo foo="foo" />));
204+
}).toErrorDev(
197205
'`Foo` uses `getDerivedStateFromProps` but its initial state is ' +
198206
'undefined. This is not recommended. Instead, define the initial state by ' +
199207
'assigning an object to `this.state` in the constructor of `Foo`. ' +

0 commit comments

Comments
 (0)