Skip to content

Commit 99aa082

Browse files
authored
Remove unstable_flushControlled (#26397)
This API has been fully replaced by `flushSync`.
1 parent 47cf4e5 commit 99aa082

File tree

8 files changed

+0
-125
lines changed

8 files changed

+0
-125
lines changed

packages/react-dom/index.classic.fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export {
2929
unmountComponentAtNode,
3030
unstable_batchedUpdates,
3131
unstable_createEventHandle,
32-
unstable_flushControlled,
3332
unstable_renderSubtreeIntoContainer,
3433
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
3534
prefetchDNS,

packages/react-dom/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export {
2121
unmountComponentAtNode,
2222
unstable_batchedUpdates,
2323
unstable_createEventHandle,
24-
unstable_flushControlled,
2524
unstable_renderSubtreeIntoContainer,
2625
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
2726
prefetchDNS,

packages/react-dom/index.modern.fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export {
1515
flushSync,
1616
unstable_batchedUpdates,
1717
unstable_createEventHandle,
18-
unstable_flushControlled,
1918
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
2019
prefetchDNS,
2120
preconnect,

packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -306,101 +306,6 @@ describe('ReactDOMFiberAsync', () => {
306306
expect(container.textContent).toEqual('ABCD');
307307
});
308308

309-
// @gate www
310-
it('flushControlled flushes updates before yielding to browser', async () => {
311-
let inst;
312-
class Counter extends React.Component {
313-
state = {counter: 0};
314-
increment = () =>
315-
this.setState(state => ({counter: state.counter + 1}));
316-
render() {
317-
inst = this;
318-
return this.state.counter;
319-
}
320-
}
321-
const root = ReactDOMClient.createRoot(container);
322-
await act(() => root.render(<Counter />));
323-
expect(container.textContent).toEqual('0');
324-
325-
// Test that a normal update is async
326-
await act(() => {
327-
inst.increment();
328-
expect(container.textContent).toEqual('0');
329-
});
330-
expect(container.textContent).toEqual('1');
331-
332-
const ops = [];
333-
ReactDOM.unstable_flushControlled(() => {
334-
inst.increment();
335-
ReactDOM.unstable_flushControlled(() => {
336-
inst.increment();
337-
ops.push('end of inner flush: ' + container.textContent);
338-
});
339-
ops.push('end of outer flush: ' + container.textContent);
340-
});
341-
ops.push('after outer flush: ' + container.textContent);
342-
expect(ops).toEqual([
343-
'end of inner flush: 1',
344-
'end of outer flush: 1',
345-
'after outer flush: 3',
346-
]);
347-
});
348-
349-
// @gate www
350-
it('flushControlled does not flush until end of outermost batchedUpdates', () => {
351-
let inst;
352-
class Counter extends React.Component {
353-
state = {counter: 0};
354-
increment = () =>
355-
this.setState(state => ({counter: state.counter + 1}));
356-
render() {
357-
inst = this;
358-
return this.state.counter;
359-
}
360-
}
361-
ReactDOM.render(<Counter />, container);
362-
363-
const ops = [];
364-
ReactDOM.unstable_batchedUpdates(() => {
365-
inst.increment();
366-
ReactDOM.unstable_flushControlled(() => {
367-
inst.increment();
368-
ops.push('end of flushControlled fn: ' + container.textContent);
369-
});
370-
ops.push('end of batchedUpdates fn: ' + container.textContent);
371-
});
372-
ops.push('after batchedUpdates: ' + container.textContent);
373-
expect(ops).toEqual([
374-
'end of flushControlled fn: 0',
375-
'end of batchedUpdates fn: 0',
376-
'after batchedUpdates: 2',
377-
]);
378-
});
379-
380-
// @gate www
381-
it('flushControlled returns nothing', () => {
382-
// In the future, we may want to return a thenable "work" object.
383-
let inst;
384-
class Counter extends React.Component {
385-
state = {counter: 0};
386-
increment = () =>
387-
this.setState(state => ({counter: state.counter + 1}));
388-
render() {
389-
inst = this;
390-
return this.state.counter;
391-
}
392-
}
393-
ReactDOM.render(<Counter />, container);
394-
expect(container.textContent).toEqual('0');
395-
396-
const returnValue = ReactDOM.unstable_flushControlled(() => {
397-
inst.increment();
398-
return 'something';
399-
});
400-
expect(container.textContent).toEqual('1');
401-
expect(returnValue).toBe(undefined);
402-
});
403-
404309
it('ignores discrete events on a pending removed element', async () => {
405310
const disableButtonRef = React.createRef();
406311
const submitButtonRef = React.createRef();

packages/react-dom/src/__tests__/react-dom-server-rendering-stub-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe('react-dom-server-rendering-stub', () => {
3535
expect(ReactDOM.unmountComponentAtNode).toBe(undefined);
3636
expect(ReactDOM.unstable_batchedUpdates).toBe(undefined);
3737
expect(ReactDOM.unstable_createEventHandle).toBe(undefined);
38-
expect(ReactDOM.unstable_flushControlled).toBe(undefined);
3938
expect(ReactDOM.unstable_renderSubtreeIntoContainer).toBe(undefined);
4039
expect(ReactDOM.unstable_runWithPriority).toBe(undefined);
4140
});

packages/react-dom/src/client/ReactDOM.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {
3636
batchedUpdates,
3737
flushSync as flushSyncWithoutWarningIfAlreadyRendering,
3838
isAlreadyRendering,
39-
flushControlled,
4039
injectIntoDevTools,
4140
} from 'react-reconciler/src/ReactFiberReconciler';
4241
import {runWithPriority} from 'react-reconciler/src/ReactEventPriorities';
@@ -173,7 +172,6 @@ export {
173172
// exposeConcurrentModeAPIs
174173
createRoot,
175174
hydrateRoot,
176-
flushControlled as unstable_flushControlled,
177175
// Disabled behind disableUnstableRenderSubtreeIntoContainer
178176
renderSubtreeIntoContainer as unstable_renderSubtreeIntoContainer,
179177
// enableCreateEventHandleAPI

packages/react-reconciler/src/ReactFiberReconciler.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import {
6464
batchedUpdates,
6565
flushSync,
6666
isAlreadyRendering,
67-
flushControlled,
6867
deferredUpdates,
6968
discreteUpdates,
7069
flushPassiveEffects,
@@ -392,7 +391,6 @@ export {
392391
batchedUpdates,
393392
deferredUpdates,
394393
discreteUpdates,
395-
flushControlled,
396394
flushSync,
397395
isAlreadyRendering,
398396
flushPassiveEffects,

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,28 +1665,6 @@ export function isInvalidExecutionContextForEventFunction(): boolean {
16651665
return (executionContext & RenderContext) !== NoContext;
16661666
}
16671667

1668-
export function flushControlled(fn: () => mixed): void {
1669-
const prevExecutionContext = executionContext;
1670-
executionContext |= BatchedContext;
1671-
const prevTransition = ReactCurrentBatchConfig.transition;
1672-
const previousPriority = getCurrentUpdatePriority();
1673-
try {
1674-
ReactCurrentBatchConfig.transition = null;
1675-
setCurrentUpdatePriority(DiscreteEventPriority);
1676-
fn();
1677-
} finally {
1678-
setCurrentUpdatePriority(previousPriority);
1679-
ReactCurrentBatchConfig.transition = prevTransition;
1680-
1681-
executionContext = prevExecutionContext;
1682-
if (executionContext === NoContext) {
1683-
// Flush the immediate callbacks that were scheduled during this batch
1684-
resetRenderTimer();
1685-
flushSyncCallbacks();
1686-
}
1687-
}
1688-
}
1689-
16901668
// This is called by the HiddenContext module when we enter or leave a
16911669
// hidden subtree. The stack logic is managed there because that's the only
16921670
// place that ever modifies it. Which module it lives in doesn't matter for

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy