Skip to content

Commit d5d567b

Browse files
committed
Added iteration logic to access property that contains atom to selector relationship
1 parent 180a9b7 commit d5d567b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/backend/linkFiber.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Tree from './tree';
2121
import componentActionsRecord from './masterState';
2222
import { throttle, getHooksNames } from './helpers';
2323
import { Console } from 'console';
24+
import AtomsRelationship from '../app/components/AtomsRelationship';
2425

2526
// Set global variables to use in exported module and helper functions
2627
declare global {
@@ -31,14 +32,12 @@ declare global {
3132
let fiberRoot = null;
3233
let doWork = true;
3334
const circularComponentTable = new Set();
34-
let allAtomsRelationship = [];
3535
let isRecoil = false;
3636

3737
// Simple check for whether our target app uses Recoil
3838
if (window[`$recoilDebugStates`]) {
3939
isRecoil = true;
4040
}
41-
4241
function getRecoilState(): any {
4342
const RecoilSnapshotsLength = window[`$recoilDebugStates`].length;
4443
const lastRecoilSnapshot =
@@ -155,6 +154,7 @@ function traverseHooks(memoizedState: any): HookStates {
155154
return hooksStates;
156155
}
157156

157+
let allAtomsRelationship = [];
158158
/**
159159
* @method createTree
160160
* @param currentFiber A Fiber object
@@ -178,6 +178,7 @@ function createTree(
178178

179179
// These have the newest state. We update state and then
180180
// called updateSnapshotTree()
181+
181182
const {
182183
sibling,
183184
stateNode,
@@ -192,14 +193,21 @@ function createTree(
192193
treeBaseDuration,
193194
} = currentFiber;
194195

196+
if(typeof currentFiber.elementType === "function" && currentFiber.elementType.name === "RecoilRoot"){
197+
// console.log(currentFiber.memoizedState.next.memoizedState.current.getState())
198+
}
199+
200+
201+
195202
if (
196203
currentFiber.memoizedState &&
197204
currentFiber.memoizedState.next &&
198205
currentFiber.memoizedState.next.memoizedState &&
199206
currentFiber.memoizedState.next.memoizedState.deps
200207
) {
201-
208+
// console.log(currentFiber)
202209
let pointer = currentFiber.memoizedState.next;
210+
203211
while (pointer !== null){
204212
if(!Array.isArray(pointer.memoizedState)){
205213
let componentName = currentFiber.elementType.name
@@ -208,6 +216,13 @@ function createTree(
208216
}
209217
pointer = pointer.next
210218
}
219+
220+
if(currentFiber.memoizedState.next.memoizedState.deps[1].current){
221+
let getState = currentFiber.memoizedState.next.memoizedState.deps[1].current.getState()
222+
console.log(getState.graphsByVersion.entries())
223+
}
224+
225+
211226
}
212227

213228
let newState: any | { hooksState?: any[] } = {};

0 commit comments

Comments
 (0)