Skip to content

Commit 832e298

Browse files
authored
Revert accdientally merged PR (#24081)
1 parent 02b65fd commit 832e298

26 files changed

+288
-562
lines changed

packages/react-art/src/ReactART.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Surface extends React.Component {
6969
this._mountNode = createContainer(
7070
this._surface,
7171
LegacyRoot,
72+
false,
7273
null,
7374
false,
7475
false,

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

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
let JSDOM;
1111
let React;
12-
let startTransition;
1312
let ReactDOMClient;
1413
let Scheduler;
1514
let clientAct;
@@ -34,8 +33,6 @@ describe('ReactDOMFizzShellHydration', () => {
3433
ReactDOMFizzServer = require('react-dom/server');
3534
Stream = require('stream');
3635

37-
startTransition = React.startTransition;
38-
3936
textCache = new Map();
4037

4138
// Test Environment
@@ -217,36 +214,7 @@ describe('ReactDOMFizzShellHydration', () => {
217214
expect(container.textContent).toBe('Shell');
218215
});
219216

220-
test(
221-
'updating the root at lower priority than initial hydration does not ' +
222-
'force a client render',
223-
async () => {
224-
function App() {
225-
return <Text text="Initial" />;
226-
}
227-
228-
// Server render
229-
await resolveText('Initial');
230-
await serverAct(async () => {
231-
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(<App />);
232-
pipe(writable);
233-
});
234-
expect(Scheduler).toHaveYielded(['Initial']);
235-
236-
await clientAct(async () => {
237-
const root = ReactDOMClient.hydrateRoot(container, <App />);
238-
// This has lower priority than the initial hydration, so the update
239-
// won't be processed until after hydration finishes.
240-
startTransition(() => {
241-
root.render(<Text text="Updated" />);
242-
});
243-
});
244-
expect(Scheduler).toHaveYielded(['Initial', 'Updated']);
245-
expect(container.textContent).toBe('Updated');
246-
},
247-
);
248-
249-
test('updating the root while the shell is suspended forces a client render', async () => {
217+
test('updating the root before the shell hydrates forces a client render', async () => {
250218
function App() {
251219
return <AsyncText text="Shell" />;
252220
}
@@ -277,9 +245,9 @@ describe('ReactDOMFizzShellHydration', () => {
277245
root.render(<Text text="New screen" />);
278246
});
279247
expect(Scheduler).toHaveYielded([
280-
'New screen',
281248
'This root received an early update, before anything was able ' +
282249
'hydrate. Switched the entire root to client rendering.',
250+
'New screen',
283251
]);
284252
expect(container.textContent).toBe('New screen');
285253
});

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,6 @@ describe('ReactDOMRoot', () => {
253253
);
254254
});
255255

256-
it('callback passed to legacy hydrate() API', () => {
257-
container.innerHTML = '<div>Hi</div>';
258-
ReactDOM.hydrate(<div>Hi</div>, container, () => {
259-
Scheduler.unstable_yieldValue('callback');
260-
});
261-
expect(container.textContent).toEqual('Hi');
262-
expect(Scheduler).toHaveYielded(['callback']);
263-
});
264-
265256
it('warns when unmounting with legacy API (no previous content)', () => {
266257
const root = ReactDOMClient.createRoot(container);
267258
root.render(<div>Hi</div>);

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

Lines changed: 40 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727

2828
import {
2929
createContainer,
30-
createHydrationContainer,
3130
findHostInstanceWithNoPortals,
3231
updateContainer,
3332
flushSync,
@@ -110,81 +109,34 @@ function noopOnRecoverableError() {
110109

111110
function legacyCreateRootFromDOMContainer(
112111
container: Container,
113-
initialChildren: ReactNodeList,
114-
parentComponent: ?React$Component<any, any>,
115-
callback: ?Function,
116-
isHydrationContainer: boolean,
112+
forceHydrate: boolean,
117113
): FiberRoot {
118-
if (isHydrationContainer) {
119-
if (typeof callback === 'function') {
120-
const originalCallback = callback;
121-
callback = function() {
122-
const instance = getPublicRootInstance(root);
123-
originalCallback.call(instance);
124-
};
125-
}
126-
127-
const root = createHydrationContainer(
128-
initialChildren,
129-
callback,
130-
container,
131-
LegacyRoot,
132-
null, // hydrationCallbacks
133-
false, // isStrictMode
134-
false, // concurrentUpdatesByDefaultOverride,
135-
'', // identifierPrefix
136-
noopOnRecoverableError,
137-
// TODO(luna) Support hydration later
138-
null,
139-
);
140-
container._reactRootContainer = root;
141-
markContainerAsRoot(root.current, container);
142-
143-
const rootContainerElement =
144-
container.nodeType === COMMENT_NODE ? container.parentNode : container;
145-
listenToAllSupportedEvents(rootContainerElement);
146-
147-
flushSync();
148-
return root;
149-
} else {
150-
// First clear any existing content.
114+
// First clear any existing content.
115+
if (!forceHydrate) {
151116
let rootSibling;
152117
while ((rootSibling = container.lastChild)) {
153118
container.removeChild(rootSibling);
154119
}
120+
}
155121

156-
if (typeof callback === 'function') {
157-
const originalCallback = callback;
158-
callback = function() {
159-
const instance = getPublicRootInstance(root);
160-
originalCallback.call(instance);
161-
};
162-
}
163-
164-
const root = createContainer(
165-
container,
166-
LegacyRoot,
167-
null, // hydrationCallbacks
168-
false, // isStrictMode
169-
false, // concurrentUpdatesByDefaultOverride,
170-
'', // identifierPrefix
171-
noopOnRecoverableError, // onRecoverableError
172-
null, // transitionCallbacks
173-
);
174-
container._reactRootContainer = root;
175-
markContainerAsRoot(root.current, container);
176-
177-
const rootContainerElement =
178-
container.nodeType === COMMENT_NODE ? container.parentNode : container;
179-
listenToAllSupportedEvents(rootContainerElement);
122+
const root = createContainer(
123+
container,
124+
LegacyRoot,
125+
forceHydrate,
126+
null, // hydrationCallbacks
127+
false, // isStrictMode
128+
false, // concurrentUpdatesByDefaultOverride,
129+
'', // identifierPrefix
130+
noopOnRecoverableError, // onRecoverableError
131+
null, // transitionCallbacks
132+
);
133+
markContainerAsRoot(root.current, container);
180134

181-
// Initial mount should not be batched.
182-
flushSync(() => {
183-
updateContainer(initialChildren, root, parentComponent, callback);
184-
});
135+
const rootContainerElement =
136+
container.nodeType === COMMENT_NODE ? container.parentNode : container;
137+
listenToAllSupportedEvents(rootContainerElement);
185138

186-
return root;
187-
}
139+
return root;
188140
}
189141

190142
function warnOnInvalidCallback(callback: mixed, callerName: string): void {
@@ -212,30 +164,39 @@ function legacyRenderSubtreeIntoContainer(
212164
warnOnInvalidCallback(callback === undefined ? null : callback, 'render');
213165
}
214166

215-
const maybeRoot = container._reactRootContainer;
216-
let root: FiberRoot;
217-
if (!maybeRoot) {
167+
let root = container._reactRootContainer;
168+
let fiberRoot: FiberRoot;
169+
if (!root) {
218170
// Initial mount
219-
root = legacyCreateRootFromDOMContainer(
171+
root = container._reactRootContainer = legacyCreateRootFromDOMContainer(
220172
container,
221-
children,
222-
parentComponent,
223-
callback,
224173
forceHydrate,
225174
);
175+
fiberRoot = root;
176+
if (typeof callback === 'function') {
177+
const originalCallback = callback;
178+
callback = function() {
179+
const instance = getPublicRootInstance(fiberRoot);
180+
originalCallback.call(instance);
181+
};
182+
}
183+
// Initial mount should not be batched.
184+
flushSync(() => {
185+
updateContainer(children, fiberRoot, parentComponent, callback);
186+
});
226187
} else {
227-
root = maybeRoot;
188+
fiberRoot = root;
228189
if (typeof callback === 'function') {
229190
const originalCallback = callback;
230191
callback = function() {
231-
const instance = getPublicRootInstance(root);
192+
const instance = getPublicRootInstance(fiberRoot);
232193
originalCallback.call(instance);
233194
};
234195
}
235196
// Update
236-
updateContainer(children, root, parentComponent, callback);
197+
updateContainer(children, fiberRoot, parentComponent, callback);
237198
}
238-
return getPublicRootInstance(root);
199+
return getPublicRootInstance(fiberRoot);
239200
}
240201

241202
export function findDOMNode(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ export function createRoot(
225225
const root = createContainer(
226226
container,
227227
ConcurrentRoot,
228+
false,
228229
null,
229230
isStrictMode,
230231
concurrentUpdatesByDefaultOverride,
@@ -301,7 +302,6 @@ export function hydrateRoot(
301302

302303
const root = createHydrationContainer(
303304
initialChildren,
304-
null,
305305
container,
306306
ConcurrentRoot,
307307
hydrationCallbacks,

packages/react-dom/src/events/ReactDOMEventListener.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import {
5353
setCurrentUpdatePriority,
5454
} from 'react-reconciler/src/ReactEventPriorities';
5555
import ReactSharedInternals from 'shared/ReactSharedInternals';
56-
import {isRootDehydrated} from 'react-reconciler/src/ReactFiberShellHydration';
5756

5857
const {ReactCurrentBatchConfig} = ReactSharedInternals;
5958

@@ -387,7 +386,7 @@ export function findInstanceBlockingEvent(
387386
targetInst = null;
388387
} else if (tag === HostRoot) {
389388
const root: FiberRoot = nearestMounted.stateNode;
390-
if (isRootDehydrated(root)) {
389+
if (root.isDehydrated) {
391390
// If this happens during a replay something went wrong and it might block
392391
// the whole system.
393392
return getContainerFromFiber(nearestMounted);

packages/react-dom/src/events/ReactDOMEventReplaying.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import {
3939
} from '../client/ReactDOMComponentTree';
4040
import {HostRoot, SuspenseComponent} from 'react-reconciler/src/ReactWorkTags';
4141
import {isHigherEventPriority} from 'react-reconciler/src/ReactEventPriorities';
42-
import {isRootDehydrated} from 'react-reconciler/src/ReactFiberShellHydration';
4342

4443
let _attemptSynchronousHydration: (fiber: Object) => void;
4544

@@ -415,7 +414,7 @@ function attemptExplicitHydrationTarget(
415414
}
416415
} else if (tag === HostRoot) {
417416
const root: FiberRoot = nearestMounted.stateNode;
418-
if (isRootDehydrated(root)) {
417+
if (root.isDehydrated) {
419418
queuedTarget.blockedOn = getContainerFromFiber(nearestMounted);
420419
// We don't currently have a way to increase the priority of
421420
// a root other than sync.

packages/react-native-renderer/src/ReactFabric.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ function render(
215215
root = createContainer(
216216
containerTag,
217217
concurrentRoot ? ConcurrentRoot : LegacyRoot,
218+
false,
218219
null,
219220
false,
220221
null,

packages/react-native-renderer/src/ReactNativeRenderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ function render(
211211
root = createContainer(
212212
containerTag,
213213
LegacyRoot,
214+
false,
214215
null,
215216
false,
216217
null,

packages/react-noop-renderer/src/createReactNoop.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
974974
root = NoopRenderer.createContainer(
975975
container,
976976
tag,
977+
false,
977978
null,
978979
null,
979980
false,
@@ -995,6 +996,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
995996
const fiberRoot = NoopRenderer.createContainer(
996997
container,
997998
ConcurrentRoot,
999+
false,
9981000
null,
9991001
null,
10001002
false,
@@ -1027,6 +1029,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
10271029
const fiberRoot = NoopRenderer.createContainer(
10281030
container,
10291031
LegacyRoot,
1032+
false,
10301033
null,
10311034
null,
10321035
false,

0 commit comments

Comments
 (0)