* Small tweaks to SSR to match #14594 * Remove unnecessary comparison
This commit is contained in:
parent
17d70df919
commit
be457ca685
|
@ -286,29 +286,26 @@ export function useReducer<S, A>(
|
|||
}
|
||||
}
|
||||
|
||||
function useMemo<T>(
|
||||
nextCreate: () => T,
|
||||
inputs: Array<mixed> | void | null,
|
||||
): T {
|
||||
function useMemo<T>(nextCreate: () => T, deps: Array<mixed> | void | null): T {
|
||||
currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
|
||||
workInProgressHook = createWorkInProgressHook();
|
||||
|
||||
const nextInputs =
|
||||
inputs !== undefined && inputs !== null ? inputs : [nextCreate];
|
||||
const nextDeps = deps === undefined ? null : deps;
|
||||
|
||||
if (
|
||||
workInProgressHook !== null &&
|
||||
workInProgressHook.memoizedState !== null
|
||||
) {
|
||||
if (workInProgressHook !== null) {
|
||||
const prevState = workInProgressHook.memoizedState;
|
||||
const prevInputs = prevState[1];
|
||||
if (areHookInputsEqual(nextInputs, prevInputs)) {
|
||||
return prevState[0];
|
||||
if (prevState !== null) {
|
||||
if (nextDeps !== null) {
|
||||
const prevDeps = prevState[1];
|
||||
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
||||
return prevState[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nextValue = nextCreate();
|
||||
workInProgressHook.memoizedState = [nextValue, nextInputs];
|
||||
workInProgressHook.memoizedState = [nextValue, nextDeps];
|
||||
return nextValue;
|
||||
}
|
||||
|
||||
|
@ -330,7 +327,7 @@ function useRef<T>(initialValue: T): {current: T} {
|
|||
|
||||
export function useLayoutEffect(
|
||||
create: () => mixed,
|
||||
inputs: Array<mixed> | void | null,
|
||||
deps: Array<mixed> | void | null,
|
||||
) {
|
||||
if (__DEV__) {
|
||||
currentHookNameInDev = 'useLayoutEffect';
|
||||
|
@ -388,7 +385,7 @@ function dispatchAction<A>(
|
|||
|
||||
export function useCallback<T>(
|
||||
callback: T,
|
||||
inputs: Array<mixed> | void | null,
|
||||
deps: Array<mixed> | void | null,
|
||||
): T {
|
||||
// Callbacks are passed as they are in the server environment.
|
||||
return callback;
|
||||
|
|
|
@ -303,7 +303,7 @@ class ReactShallowRenderer {
|
|||
this._validateCurrentlyRenderingComponent();
|
||||
this._createWorkInProgressHook();
|
||||
|
||||
const nextDeps = deps !== undefined && deps !== null ? deps : null;
|
||||
const nextDeps = deps !== undefined ? deps : null;
|
||||
|
||||
if (
|
||||
this._workInProgressHook !== null &&
|
||||
|
|
Loading…
Reference in New Issue