You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Initilize the set of React Hooks that do not generate a state:
288
+
constnoStateReactHooks=newSet(['useContext']);
276
289
// Initialize counter for the default naming. If user use reactHook, such as useState, react will only pass in the value, and not the name of the state.
277
290
letstateCounter=1;
291
+
letrefCounter=1;
292
+
293
+
// Loop through each hook inside the _debugHookTypes array.
294
+
// NOTE: _debugHookTypes.length === height of memoizedState tree.
278
295
for(consthookof_debugHookTypes){
279
-
if(reactHooks.has(hook)){
280
-
letstateData=memoizedState?.memoizedState;
281
-
// ReactHook condition:
282
-
if(typeofstateData!=='object'){
283
-
constdefaultName=`state${stateCounter}`;
284
-
stateData={[defaultName]: stateData};
285
-
stateCounter++;
286
-
}
287
-
// If user does not use reactHook => state is store in memoizedState array, at i = 0
288
-
else{
289
-
stateData=stateData[0];
290
-
}
291
-
//Trim the current level of memoizedState data:
292
-
console.log({ stateData });
293
-
convertDataToString(stateData,reactimeStateData);
296
+
// useContext does not create any state => skip
297
+
if(hook==='useContext'){
298
+
continue;
299
+
}
300
+
// If user use useState reactHook => React will only pass in the value of state & not the name of the state => create a default name:
// If user use Redux to contain their context => the context object will be stored using useMemo Hook, as of for Rect Dev Tool v4.27.2
313
+
// Note: Provider is not a reserved component name for redux. User may name their component as Provider, which will break this logic. However, it is a good assumption that if user have a custom provider component, it would have a more specific naming such as ThemeProvider.
// if user uses useContext hook, context data will be stored in memoizedProps.value of the Context.Provider component => grab context object stored in memoizedprops
410
449
// Different from other provider, such as Routes, BrowswerRouter, ReactRedux, ..., Context.Provider does not have a displayName
450
+
// TODO: need to render this context provider when user use usContext hook.
0 commit comments