48
49
let primitiveStackCache: null | Map<string, Array<any>> = null;
50
51
-type MemoCache = {
52
- data: Array<Array<any>>,
53
- index: number,
54
-};
55
-
56
-type FunctionComponentUpdateQueue = {
57
- memoCache?: MemoCache | null,
58
-};
59
-
51
type Hook = {
52
memoizedState: any,
53
next: Hook | null,
63
- updateQueue: FunctionComponentUpdateQueue | null,
54
};
55
56
function getPrimitiveStackCache(): Map<string, Array<any>> {
317
return id;
318
}
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
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
+ return [];
325
}
326
327
const Dispatcher: DispatcherType = {
690
renderFunction: Props => React$Node,
691
props: Props,
692
currentDispatcher: ?CurrentDispatcherRef,
728
- includeHooksSource?: boolean = false,
693
+ includeHooksSource: boolean = false,
694
): HooksTree {
695
// DevTools will pass the current renderer's injected dispatcher.
696
// Other apps might compile debug hooks as part of their app though.
781
export function inspectHooksOfFiber(
782
fiber: Fiber,
783
currentDispatcher: ?CurrentDispatcherRef,
819
- includeHooksSource?: boolean = false,
784
+ includeHooksSource: boolean = false,
785
): HooksTree {
786
// DevTools will pass the current renderer's injected dispatcher.
787
// Other apps might compile debug hooks as part of their app though.