(nextCreate: () => T, deps: Array<mixed> | void | null)
| 441 | } |
| 442 | |
| 443 | function useMemo<T>(nextCreate: () => T, deps: Array<mixed> | void | null): T { |
| 444 | currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); |
| 445 | workInProgressHook = createWorkInProgressHook(); |
| 446 | |
| 447 | const nextDeps = deps === undefined ? null : deps; |
| 448 | |
| 449 | if (workInProgressHook !== null) { |
| 450 | const prevState = workInProgressHook.memoizedState; |
| 451 | if (prevState !== null) { |
| 452 | if (nextDeps !== null) { |
| 453 | const prevDeps = prevState[1]; |
| 454 | if (areHookInputsEqual(nextDeps, prevDeps)) { |
| 455 | return prevState[0]; |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | if (__DEV__) { |
| 462 | isInHookUserCodeInDev = true; |
| 463 | } |
| 464 | const nextValue = nextCreate(); |
| 465 | if (__DEV__) { |
| 466 | isInHookUserCodeInDev = false; |
| 467 | } |
| 468 | // $FlowFixMe[incompatible-use] found when upgrading Flow |
| 469 | workInProgressHook.memoizedState = [nextValue, nextDeps]; |
| 470 | return nextValue; |
| 471 | } |
| 472 | |
| 473 | function useRef<T>(initialValue: T): {current: T} { |
| 474 | currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); |
no test coverage detected