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
@@ -160,28 +163,23 @@ export default function createTree(currentFiberNode: Fiber): Tree {
160
163
// componentName = 'Context';
161
164
// }
162
165
163
-
// // DEPRECATED: This code might have worked previously. However, with the update of React Dev Tool, context can no longer be pulled using this method.
164
-
// // Check to see if the component has any context:
165
-
// // if the component uses the useContext hook, we want to grab the context object and add it to the componentData object for that fiber
// ---------OBTAIN STATE & SET STATE METHODS FROM CLASS COMPONENT-----------
171
-
// Check if node is a stateful class component when user use setState.
167
+
// Check if currentFiberNode is a stateful class component when user use setState.
172
168
// 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
173
169
// Example: for tic-tac-toe demo-app: Board is a stateful component that use setState to store state data.
// Save component's state and setState() function to our record for future time-travel state changing. Add record index to snapshot so we can retrieve.
// --------OBTAIN STATE & DISPATCH METHODS FROM FUNCTIONAL COMPONENT--------
184
-
// Check if node is a hooks useState function
180
+
// Check if currentFiberNode is a stateful functional component when user use useState hook.
181
+
// If user use useState to define/manage state, the state object will be stored in memoizedState => grab the state object & its update method (dispatch) from memoizedState
182
+
// Example: for Stateful buttons demo-app: Increment is a stateful component that use useState hook to store state data.
185
183
if(
186
184
(tag===FunctionComponent||
187
185
tag===IndeterminateComponent||
@@ -191,20 +189,21 @@ export default function createTree(currentFiberNode: Fiber): Tree {
191
189
){
192
190
if(memoizedState.queue){
193
191
try{
192
+
// Obtain all hooksStates & the corresponding udpate method from memoizedState
// Save component's state and dispatch() function to our record for future time-travel state changing. Add record index to snapshot so we can retrieve.
// ------------FILTER DATA FROM REACT DEV TOOL && CONVERT TO STRING-------------
11
11
/**
12
12
* 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 sent to reacTime front end.
13
+
* NOTE: the formating is important since Chrome will only accept JSON.stringfiable object. Circular object & function are not JSON stringifiable.
13
14
*
14
15
* @param reactDevData - The data object obtained from React Devtool. Ex: memoizedProps, memoizedState
15
16
* @param reactimeData - The cached data from the current component. This can be data about states, context and/or props of the component.
@@ -64,8 +65,10 @@ export function filterAndFormatData(
64
65
* @return An array of array of HookStateItem objects
Copy file name to clipboardExpand all lines: src/backend/models/masterState.ts
+3-6Lines changed: 3 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,6 @@
3
3
// For class components, there will be one "component" for each snapshot
4
4
// For functional components that utilize Hooks, there will be one "component"
5
5
6
-
import{index}from'd3';
7
-
8
6
// for each setter/getter every time we have a new snapshot
9
7
letcomponentActionsRecord=[];
10
8
@@ -18,12 +16,11 @@ export default {
18
16
19
17
/**
20
18
* @function saveNew - Adds a new component to the componentActionsRecord array and returns its index.
21
-
* @param component
22
-
* @returnsnumber
19
+
* @param component - An object that contains bound update method. For class component, the udpate method is `setState`. For functional component, the update method is `dispatch`.
20
+
* @returns- the index of the newly added component
Copy file name to clipboardExpand all lines: src/backend/types/backendTypes.ts
+27-14Lines changed: 27 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -42,25 +42,38 @@ export interface MsgData {
42
42
43
43
/**
44
44
* @type ComponentData -
45
-
* @member index -
46
-
* @member hooksIndex -
47
-
* @member actualDuration -
48
-
* @member actualStartTime -
49
-
* @member selfBaseDuration -
50
-
* @member treeBaseDuration -
51
-
* @member props -
45
+
* @member actualDuration - The time taken to render the current Fiber node and its descendants during the previous render cycle. This value is used to optimize the rendering of components and to provide performance metrics to developers.
46
+
* @member actualStartTime - The time at which the rendering of the current Fiber node started during the previous render cycle.
47
+
* @member context - {in experiment} - An object contains all context information of the current component
48
+
* @member index - {class component only} - The index of the bound setState method stored in `componentActionsRecord`
49
+
* @member hooksState - {functional component only} - An object contains all states of the current functional component
50
+
* @member hooksIndex - {functional component only} - An array of index of the bound dispatch method stored in `componentActionsRecord`
51
+
* @member props - An object contains all props of the current component
52
+
* @member selfBaseDuration - The base duration of the current Fiber node's render phase (excluding the time taken to render its children). This field is only set when the enableProfilerTimer flag is enabled.
53
+
* @member state - {class component only} - An object contains all states of the current class component
54
+
* @member treeBaseDuration - The total base duration of the current Fiber node's subtree. This field is only set when the enableProfilerTimer flag is enabled.
52
55
*/
53
56
exportinterfaceComponentData{
57
+
/** The time taken to render the current Fiber node and its descendants during the previous render cycle. */
54
58
actualDuration?: number;
59
+
/** The time at which the rendering of the current Fiber node started during the previous render cycle. */
55
60
actualStartTime?: number;
56
-
selfBaseDuration?: number;
57
-
treeBaseDuration?: number;
58
-
props: {[key: string]: any};
61
+
/** {in experiment} - An object contains all context information of the current component */
59
62
context: {};
60
-
state: {[key: string]: any}|null;
63
+
/** {class component only} - The index of the bound setState method stored in `componentActionsRecord` */
64
+
index: number|null;
65
+
/** {functional component only} - An object contains all states of the current functional component */
61
66
hooksState: {}|null;
67
+
/** {functional component only} - An array of index of the bound dispatch method stored in `componentActionsRecord` */
62
68
hooksIndex: number[]|null;
63
-
index: number|null;
69
+
/** An object contains all props of the current component */
70
+
props: {[key: string]: any};
71
+
/** The base duration of the current Fiber node's render phase (excluding the time taken to render its children). */
72
+
selfBaseDuration?: number;
73
+
/** An object contains all states of the current class component */
74
+
state: {[key: string]: any}|null;
75
+
/** The total base duration of the current Fiber node's subtree. */
76
+
treeBaseDuration?: number;
64
77
}
65
78
66
79
/**
@@ -108,9 +121,9 @@ export type WorkTag =
108
121
exportconstFunctionComponent=0;
109
122
exportconstClassComponent=1;
110
123
/** Before we know whether it is function or class */
111
-
exportconstIndeterminateComponent=2;
124
+
exportconstIndeterminateComponent=2;
112
125
/** Root of a host tree. Could be nested inside another node. */
113
-
exportconstHostRoot=3;
126
+
exportconstHostRoot=3;
114
127
/** A subtree. Could be an entry point to a different renderer. */
0 commit comments