mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Check if we're in sync mode before deprioritizing hidden subtrees
This commit is contained in:
1 parent
81eef12507
commit
4ef197b7d4
3 files changed
+12
-8
No files matched your search
@@ -1160,15 +1160,16 @@ describe('ReactUpdates', () => {
|
||||
expect(mounts).toBe(1);
|
||||
});
|
||||
|
||||
it('mounts and unmounts are sync even in a batch', done => {
|
||||
it('mounts and unmounts are sync even in a batch', () => {
|
||||
var ops = [];
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.unstable_batchedUpdates(() => {
|
||||
ReactDOM.render(<div>Hello</div>, container);
|
||||
expect(container.textContent).toEqual('Hello');
|
||||
ops.push(container.textContent);
|
||||
ReactDOM.unmountComponentAtNode(container);
|
||||
expect(container.textContent).toEqual('');
|
||||
done();
|
||||
ops.push(container.textContent);
|
||||
});
|
||||
expect(ops).toEqual(['Hello', '']);
|
||||
});
|
||||
|
||||
it('does not re-render if state update is null', () => {
|
||||
@@ -1192,7 +1193,7 @@ describe('ReactUpdates', () => {
|
||||
|
||||
// Will change once we switch to async by default
|
||||
it('synchronously renders hidden subtrees', () => {
|
||||
let container = document.createElement('div');
|
||||
const container = document.createElement('div');
|
||||
let ops = [];
|
||||
|
||||
function Baz() {
|
||||
|
||||
@@ -77,7 +77,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
|
||||
getPriorityContext : () => PriorityLevel,
|
||||
) {
|
||||
|
||||
const { shouldSetTextContent } = config;
|
||||
const { shouldSetTextContent, useSyncScheduling } = config;
|
||||
|
||||
const {
|
||||
pushHostContext,
|
||||
@@ -357,7 +357,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
|
||||
);
|
||||
}
|
||||
} else if (nextProps === null || memoizedProps === nextProps) {
|
||||
if (memoizedProps.hidden &&
|
||||
if (!useSyncScheduling &&
|
||||
memoizedProps.hidden &&
|
||||
workInProgress.pendingWorkPriority !== OffscreenPriority) {
|
||||
// This subtree still has work, but it should be deprioritized so we need
|
||||
// to bail out and not do any work yet.
|
||||
@@ -398,7 +399,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
|
||||
|
||||
markRef(current, workInProgress);
|
||||
|
||||
if (nextProps.hidden &&
|
||||
if (!useSyncScheduling &&
|
||||
nextProps.hidden &&
|
||||
workInProgress.pendingWorkPriority !== OffscreenPriority) {
|
||||
// If this host component is hidden, we can bail out on the children.
|
||||
// We'll rerender the children later at the lower priority.
|
||||
|
||||
Reference in new issue
Block a user