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
Copy file name to clipboardExpand all lines: src/backend/linkFiber.ts
+46-47Lines changed: 46 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ import updateSnapShotTree from './snapShot';
63
63
64
64
// throttle returns a function that can be called any number of times (possibly in quick succession) but will only invoke the callback at most once every x ms
65
65
// getHooksNames - helper function to grab the getters/setters from `elementType`
// Set global variables to use in exported module and helper functions
69
69
declare global {
@@ -92,12 +92,12 @@ function traverseHooks(memoizedState: any): HookStates {
92
92
consthooksStates: HookStates=[];
93
93
while(memoizedState){
94
94
// the !== undefined conditional is necessary here for correctly displaying react hooks because TypeScript recognizes 0 and "" as falsey value - DO NOT REMOVE
95
-
// if (memoizedState.memoizedState !== undefined) {
96
-
hooksStates.push({
97
-
component: memoizedState.queue,
98
-
state: memoizedState.memoizedState,
99
-
});
100
-
// }
95
+
if(memoizedState.queue){
96
+
hooksStates.push({
97
+
component: memoizedState.queue,
98
+
state: memoizedState.memoizedState,
99
+
});
100
+
}
101
101
memoizedState=memoizedState.next;
102
102
}
103
103
returnhooksStates;
@@ -175,13 +175,12 @@ const exclude = new Set([
175
175
'$$typeof',
176
176
'@@observable',
177
177
]);
178
-
// ---------------------FILTER DATA FROM REACT DEV TOOL-------------------------
178
+
// ------------FILTER DATA FROM REACT DEV TOOL && CONVERT TO STRING-------------
179
179
/**
180
-
* This recursive function is used to grab the state/props/context of children components
181
-
and push them into the parent componenent react elements throw errors on client side of application - convert react/functions into string
182
-
*
180
+
* This function receives raw Data from REACT DEV TOOL and filter the Data based on the exclude list. The filterd data is then converted to string (if applicable) before being send to reacTime front end.
181
+
*
183
182
* @param reactDevData - The data object obtained from React Devtool. Ex: memoizedProps, memoizedState
184
-
* @param reactimeData - The cached data from the current component. This can be data about states, context and/or props of the component.
183
+
* @param reactimeData - The cached data from the current component. This can be data about states, context and/or props of the component.
185
184
* @returns The update component data object to send to front end of ReactTime
186
185
*/
187
186
functionconvertDataToString(
@@ -197,7 +196,13 @@ function convertDataToString(
197
196
// If value at key is a function, assign key with value 'function' to reactimeData object
198
197
elseif(typeofreactDevData[key]==='function'){
199
198
reactimeData[key]='function';
200
-
}else{
199
+
}
200
+
// If value at key is an object/array and not null => JSON stringify the value
// ------------APPEND STATE & CONTEXT DATA FROM REACT DEV TOOL----------------
373
-
// stateNode
374
-
// If user use setState to define/manage state, the state object will be stored in stateNode.state => grab the state object stored in the stateNode.state
375
-
// Example: for tic-tac-toe demo-app: Board is a stateful component that use setState to store state data.
// Note: if user use ReactHook, memoizedState.memoizedState can be a falsy value such as null, false, ... => need to specify this data is not undefined
@@ -391,12 +388,12 @@ export function createTree(
391
388
);
392
389
}
393
390
// Else if user use ReactHook to define state => all states will be stored in memoizedState => grab all states stored in the memoizedState
// if user uses useContext hook, context data will be stored in memoizedProps.value of the Context.Provider component => grab context object stored in memoizedprops
402
399
// Different from other provider, such as Routes, BrowswerRouter, ReactRedux, ..., Context.Provider does not have a displayName
// -----------OBTAIN STATE & SET STATE METHODS FOR CLASS COMPONENT------------
417
+
// Check if node is a stateful class component when user use setState.
418
+
// If user use setState to define/manage state, the state object will be stored in stateNode.state => grab the state object stored in the stateNode.state
419
+
// Example: for tic-tac-toe demo-app: Board is a stateful component that use setState to store state data.
0 commit comments