@@ -286,29 +286,26 @@ export function useReducer<S, A>(
286
286
}
287
287
}
288
288
289
- function useMemo < T > (
290
- nextCreate: () => T ,
291
- inputs : Array < mixed > | void | null,
292
- ): T {
289
+ function useMemo < T > (nextCreate: () => T , deps : Array < mixed > | void | null): T {
293
290
currentlyRenderingComponent = resolveCurrentlyRenderingComponent ( ) ;
294
291
workInProgressHook = createWorkInProgressHook ( ) ;
295
292
296
- const nextInputs =
297
- inputs !== undefined && inputs !== null ? inputs : [ nextCreate ] ;
293
+ const nextDeps = deps === undefined ? null : deps ;
298
294
299
- if (
300
- workInProgressHook !== null &&
301
- workInProgressHook . memoizedState !== null
302
- ) {
295
+ if ( workInProgressHook !== null ) {
303
296
const prevState = workInProgressHook . memoizedState ;
304
- const prevInputs = prevState [ 1 ] ;
305
- if ( areHookInputsEqual ( nextInputs , prevInputs ) ) {
306
- return prevState [ 0 ] ;
297
+ if ( prevState !== null ) {
298
+ if ( nextDeps !== null ) {
299
+ const prevDeps = prevState [ 1 ] ;
300
+ if ( areHookInputsEqual ( nextDeps , prevDeps ) ) {
301
+ return prevState [ 0 ] ;
302
+ }
303
+ }
307
304
}
308
305
}
309
306
310
307
const nextValue = nextCreate ( ) ;
311
- workInProgressHook . memoizedState = [ nextValue , nextInputs ] ;
308
+ workInProgressHook . memoizedState = [ nextValue , nextDeps ] ;
312
309
return nextValue ;
313
310
}
314
311
@@ -330,7 +327,7 @@ function useRef<T>(initialValue: T): {current: T} {
330
327
331
328
export function useLayoutEffect (
332
329
create : ( ) => mixed ,
333
- inputs : Array < mixed > | void | null,
330
+ deps : Array < mixed > | void | null,
334
331
) {
335
332
if ( __DEV__ ) {
336
333
currentHookNameInDev = 'useLayoutEffect' ;
@@ -388,7 +385,7 @@ function dispatchAction<A>(
388
385
389
386
export function useCallback < T > (
390
387
callback: T,
391
- inputs : Array< mixed > | void | null,
388
+ deps : Array< mixed > | void | null,
392
389
): T {
393
390
// Callbacks are passed as they are in the server environment.
394
391
return callback ;
0 commit comments