mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Check if we're in sync mode before deprioritizing hidden subtrees
This commit is contained in:
committed by
Andrew Clark
parent
81eef12507
commit
4ef197b7d4
@@ -854,6 +854,7 @@ src/renderers/__tests__/ReactUpdates-test.js
|
||||
* handles reentrant mounting in synchronous mode
|
||||
* mounts and unmounts are sync even in a batch
|
||||
* does not re-render if state update is null
|
||||
* synchronously renders hidden subtrees
|
||||
|
||||
src/renderers/__tests__/refs-destruction-test.js
|
||||
* should remove refs when destroying the parent
|
||||
|
||||
@@ -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