mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
This reverts commit e9c1445ba0.
This commit is contained in:
parent
b621dab5d4
commit
18fb4d3276
|
|
@ -3314,44 +3314,4 @@ describe('ReactHooksWithNoopRenderer', () => {
|
|||
});
|
||||
expect(ReactNoop).toMatchRenderedOutput('ABC');
|
||||
});
|
||||
|
||||
it('keeps intermediate state updates (issue #18497)', () => {
|
||||
let _dispatch;
|
||||
function Counter() {
|
||||
const [list, dispatch] = React.useReducer((l, c) => l.concat([c]), []);
|
||||
_dispatch = dispatch;
|
||||
|
||||
const json = JSON.stringify(list);
|
||||
Scheduler.unstable_yieldValue('Render ' + json);
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit ' + json);
|
||||
});
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
act(() => {
|
||||
ReactNoop.render(<Counter />);
|
||||
expect(Scheduler).toFlushAndYieldThrough(['Render []', 'Commit []']);
|
||||
expect(ReactNoop).toMatchRenderedOutput('[]');
|
||||
});
|
||||
|
||||
act(() => {
|
||||
_dispatch(1);
|
||||
expect(Scheduler).toFlushAndYieldThrough(['Render [1]']);
|
||||
|
||||
_dispatch(2);
|
||||
expect(Scheduler).toFlushAndYieldThrough(['Commit [1]']);
|
||||
expect(ReactNoop).toMatchRenderedOutput('[1]');
|
||||
|
||||
expect(Scheduler).toFlushAndYieldThrough(['Render [1,2]']);
|
||||
_dispatch(3);
|
||||
|
||||
expect(Scheduler).toFlushAndYieldThrough([
|
||||
'Render [1,2,3]',
|
||||
'Commit [1,2,3]',
|
||||
]);
|
||||
expect(ReactNoop).toMatchRenderedOutput('[1,2,3]');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ function assertYieldsWereCleared(Scheduler) {
|
|||
const actualYields = Scheduler.unstable_clearYields();
|
||||
if (actualYields.length !== 0) {
|
||||
throw new Error(
|
||||
'Log of yielded values is not empty: ' +
|
||||
JSON.stringify(actualYields) +
|
||||
'. ' +
|
||||
'Log of yielded values is not empty. ' +
|
||||
'Call expect(Scheduler).toHaveYielded(...) first.'
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user