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
+21-19Lines changed: 21 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -154,17 +154,6 @@ function traverseHooks(memoizedState: any): HookStates {
154
154
returnhooksStates;
155
155
}
156
156
157
-
/**
158
-
* @function createTree
159
-
* @param currentFiber A Fiber object
160
-
* @param tree A Tree object, default initialized to an instance given 'root' and 'root'
161
-
* @param fromSibling A boolean, default initialized to false
162
-
* @return An instance of a Tree object
163
-
* This is a recursive function that runs after every Fiber commit using the following logic:
164
-
* 1. Traverse from FiberRootNode
165
-
* 2. Create an instance of custom Tree class
166
-
* 3. Build a new state snapshot
167
-
*/
168
157
// This runs after every Fiber commit. It creates a new snapshot
169
158
constexclude=newSet([
170
159
'alternate',
@@ -323,12 +312,16 @@ function trimContextData(memoizedState, componentName, _debugHookTypes: string[]
323
312
}
324
313
// -------------------------CREATE TREE TO SEND TO FRONT END--------------------
325
314
/**
315
+
* This is a recursive function that runs after every Fiber commit using the following logic:
316
+
* 1. Traverse from FiberRootNode
317
+
* 2. Create an instance of custom Tree class
318
+
* 3. Build a new state snapshot
326
319
* Every time a state change is made in the accompanying app, the extension creates a Tree “snapshot” of the current state, and adds it to the current “cache” of snapshots in the extension
327
-
*
328
-
* @param currentFiber
329
-
* @param tree
330
-
* @param fromSibling
331
-
* @returns
320
+
*@function createTree
321
+
* @param currentFiber A Fiber object
322
+
* @param tree A Tree object, default initialized to an instance given 'root' and 'root'
323
+
* @param fromSibling A boolean, default initialized to false
324
+
* @return An instance of a Tree object
332
325
*/
333
326
functioncreateTree(
334
327
currentFiber: Fiber,
@@ -426,10 +419,19 @@ function createTree(
426
419
}
427
420
428
421
// ------------APPEND STATE & CONTEXT DATA FROM REACT DEV TOOL----------------
422
+
// stateNode
423
+
// 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
424
+
// 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
431
+
if(
432
+
(tag===FunctionComponent||tag===ClassComponent)&&
433
+
memoizedState?.memoizedState!==undefined
434
+
){
433
435
// If user uses Redux, context data will be stored in memoizedState of the Provider component => grab context object stored in the memoizedState
0 commit comments