@@ -48,19 +48,9 @@ type Dispatch<A> = A => void;
48
48
49
49
let primitiveStackCache : null | Map < string , Array < any >> = null ;
50
50
51
- type MemoCache = {
52
- data : Array < Array < any >> ,
53
- index : number ,
54
- } ;
55
-
56
- type FunctionComponentUpdateQueue = {
57
- memoCache ?: MemoCache | null ,
58
- } ;
59
-
60
51
type Hook = {
61
52
memoizedState : any ,
62
53
next : Hook | null ,
63
- updateQueue : FunctionComponentUpdateQueue | null ,
64
54
} ;
65
55
66
56
function getPrimitiveStackCache ( ) : Map < string , Array < any >> {
@@ -327,36 +317,12 @@ function useId(): string {
327
317
return id ;
328
318
}
329
319
320
+ // useMemoCache is an implementation detail of Forget's memoization
321
+ // it should not be called directly in user-generated code
322
+ // we keep it as a stub for dispatcher
330
323
function useMemoCache(size: number): Array< any > {
331
- const hook = nextHook ( ) ;
332
- let memoCache : MemoCache ;
333
- if (
334
- hook !== null &&
335
- hook . updateQueue !== null &&
336
- hook . updateQueue . memoCache != null
337
- ) {
338
- memoCache = hook . updateQueue . memoCache ;
339
- } else {
340
- memoCache = {
341
- data : [ ] ,
342
- index : 0 ,
343
- } ;
344
- }
345
-
346
- let data = memoCache . data [ memoCache . index ] ;
347
- if ( data === undefined ) {
348
- const MEMO_CACHE_SENTINEL = Symbol . for ( 'react.memo_cache_sentinel' ) ;
349
- data = new Array ( size ) ;
350
- for ( let i = 0 ; i < size ; i ++ ) {
351
- data [ i ] = MEMO_CACHE_SENTINEL ;
352
- }
353
- }
354
- hookLog . push ( {
355
- primitive : 'MemoCache' ,
356
- stackError : new Error ( ) ,
357
- value : data ,
358
- } ) ;
359
- return data ;
324
+ nextHook ( ) ;
325
+ return [ ] ;
360
326
}
361
327
362
328
const Dispatcher: DispatcherType = {
@@ -725,7 +691,7 @@ export function inspectHooks<Props>(
725
691
renderFunction: Props => React$Node ,
726
692
props : Props ,
727
693
currentDispatcher : ?CurrentDispatcherRef ,
728
- includeHooksSource ? : boolean = false ,
694
+ includeHooksSource : boolean = false ,
729
695
) : HooksTree {
730
696
// DevTools will pass the current renderer's injected dispatcher.
731
697
// Other apps might compile debug hooks as part of their app though.
@@ -816,7 +782,7 @@ function resolveDefaultProps(Component: any, baseProps: any) {
816
782
export function inspectHooksOfFiber (
817
783
fiber : Fiber ,
818
784
currentDispatcher : ?CurrentDispatcherRef ,
819
- includeHooksSource ? : boolean = false ,
785
+ includeHooksSource : boolean = false ,
820
786
) : HooksTree {
821
787
// DevTools will pass the current renderer's injected dispatcher.
822
788
// Other apps might compile debug hooks as part of their app though.
0 commit comments