@@ -48,19 +48,9 @@ type Dispatch<A> = A => void;
4848
4949let primitiveStackCache : null | Map < string , Array < any >> = null ;
5050
51- type MemoCache = {
52- data : Array < Array < any >> ,
53- index : number ,
54- } ;
55-
56- type FunctionComponentUpdateQueue = {
57- memoCache ?: MemoCache | null ,
58- } ;
59-
6051type Hook = {
6152 memoizedState : any ,
6253 next : Hook | null ,
63- updateQueue : FunctionComponentUpdateQueue | null ,
6454} ;
6555
6656function getPrimitiveStackCache ( ) : Map < string , Array < any >> {
@@ -327,36 +317,12 @@ function useId(): string {
327317 return id ;
328318}
329319
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
330323function 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 [ ] ;
360326}
361327
362328const Dispatcher: DispatcherType = {
@@ -725,7 +691,7 @@ export function inspectHooks<Props>(
725691 renderFunction: Props => React$Node ,
726692 props : Props ,
727693 currentDispatcher : ?CurrentDispatcherRef ,
728- includeHooksSource ? : boolean = false ,
694+ includeHooksSource : boolean = false ,
729695) : HooksTree {
730696 // DevTools will pass the current renderer's injected dispatcher.
731697 // Other apps might compile debug hooks as part of their app though.
@@ -816,7 +782,7 @@ function resolveDefaultProps(Component: any, baseProps: any) {
816782export function inspectHooksOfFiber (
817783 fiber : Fiber ,
818784 currentDispatcher : ?CurrentDispatcherRef ,
819- includeHooksSource ? : boolean = false ,
785+ includeHooksSource : boolean = false ,
820786) : HooksTree {
821787 // DevTools will pass the current renderer's injected dispatcher.
822788 // Other apps might compile debug hooks as part of their app though.
0 commit comments