Skip to content

Commit be457ca

Browse files
authored
Small tweaks to SSR to match #14594 (#14618)
* Small tweaks to SSR to match #14594 * Remove unnecessary comparison
1 parent 17d70df commit be457ca

2 files changed

Lines changed: 14 additions & 17 deletions

File tree

‎packages/react-dom/src/server/ReactPartialRendererHooks.js‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -286,29 +286,26 @@ export function useReducer<S, A>(
286286
}
287287
}
288288

289-
functionuseMemo<T>(
290-
nextCreate: () =>T,
291-
inputs: Array<mixed> | void | null,
292-
): T {
289+
functionuseMemo<T>(nextCreate: () =>T,deps: Array<mixed> | void | null): T {
293290
currentlyRenderingComponent=resolveCurrentlyRenderingComponent();
294291
workInProgressHook=createWorkInProgressHook();
295292

296-
constnextInputs=
297-
inputs!==undefined&&inputs!==null ? inputs : [nextCreate];
293+
constnextDeps=deps===undefined ? null : deps;
298294

299-
if(
300-
workInProgressHook!==null&&
301-
workInProgressHook.memoizedState!==null
302-
){
295+
if(workInProgressHook!==null){
303296
const prevState =workInProgressHook.memoizedState;
304-
constprevInputs=prevState[1];
305-
if(areHookInputsEqual(nextInputs,prevInputs)){
306-
returnprevState[0];
297+
if(prevState!==null){
298+
if(nextDeps!==null){
299+
constprevDeps=prevState[1];
300+
if(areHookInputsEqual(nextDeps,prevDeps)){
301+
returnprevState[0];
302+
}
303+
}
307304
}
308305
}
309306

310307
constnextValue=nextCreate();
311-
workInProgressHook.memoizedState=[nextValue,nextInputs];
308+
workInProgressHook.memoizedState=[nextValue,nextDeps];
312309
returnnextValue;
313310
}
314311

@@ -330,7 +327,7 @@ function useRef<T>(initialValue: T): {current: T} {
330327

331328
exportfunctionuseLayoutEffect(
332329
create: ()=>mixed,
333-
inputs: Array<mixed> | void | null,
330+
deps: Array<mixed> | void | null,
334331
) {
335332
if(__DEV__){
336333
currentHookNameInDev='useLayoutEffect';
@@ -388,7 +385,7 @@ function dispatchAction<A>(
388385

389386
exportfunctionuseCallback<T>(
390387
callback: T,
391-
inputs: Array<mixed> | void | null,
388+
deps: Array<mixed> | void | null,
392389
): T {
393390
// Callbacks are passed as they are in the server environment.
394391
returncallback;

‎packages/react-test-renderer/src/ReactShallowRenderer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class ReactShallowRenderer {
303303
this._validateCurrentlyRenderingComponent();
304304
this._createWorkInProgressHook();
305305

306-
constnextDeps=deps!==undefined&&deps!==null? deps : null;
306+
constnextDeps=deps!==undefined ? deps : null;
307307

308308
if(
309309
this._workInProgressHook!==null&&

0 commit comments

Comments
 (0)