Skip to content

Commit 37a9d8a

Browse files
committed
Merge branch 'implementAtomsMap' of https://github.com/hienqn/reactime into implementAtomsMap
2 parents 8395490 + e452269 commit 37a9d8a

File tree

3 files changed

+63
-56
lines changed

3 files changed

+63
-56
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function AtomsRelationship(props) {
113113
// let { hierarchy } = props;
114114
// let root = JSON.parse(JSON.stringify(hierarchy));
115115
// let HistoryRef = React.createRef(root); //React.createRef(root);
116-
116+
console.log('Props', props.atomsRel);
117117
useEffect(() => {
118118
maked3Tree();
119119
}, [root]);
@@ -164,52 +164,53 @@ function AtomsRelationship(props) {
164164
loader={<div>Loading Chart</div>}
165165
data={[
166166
['From', 'To', 'Weight'],
167-
['Brazil', 'Portugal', 5],
168-
['Brazil', 'France', 1],
169-
['Brazil', 'Spain', 1],
170-
['Brazil', 'England', 1],
171-
['Canada', 'Portugal', 1],
172-
['Canada', 'France', 5],
173-
['Canada', 'England', 1],
174-
['Mexico', 'Portugal', 1],
175-
['Mexico', 'France', 1],
176-
['Mexico', 'Spain', 5],
177-
['Mexico', 'England', 1],
178-
['USA', 'Portugal', 1],
179-
['USA', 'France', 1],
180-
['USA', 'Spain', 1],
181-
['USA', 'England', 5],
182-
['Portugal', 'Angola', 2],
183-
['Portugal', 'Senegal', 1],
184-
['Portugal', 'Morocco', 1],
185-
['Portugal', 'South Africa', 3],
186-
['France', 'Angola', 1],
187-
['France', 'Senegal', 3],
188-
['France', 'Mali', 3],
189-
['France', 'Morocco', 3],
190-
['France', 'South Africa', 1],
191-
['Spain', 'Senegal', 1],
192-
['Spain', 'Morocco', 3],
193-
['Spain', 'South Africa', 1],
194-
['England', 'Angola', 1],
195-
['England', 'Senegal', 1],
196-
['England', 'Morocco', 2],
197-
['England', 'South Africa', 7],
198-
['South Africa', 'China', 5],
199-
['South Africa', 'India', 1],
200-
['South Africa', 'Japan', 3],
201-
['Angola', 'China', 5],
202-
['Angola', 'India', 1],
203-
['Angola', 'Japan', 3],
204-
['Senegal', 'China', 5],
205-
['Senegal', 'India', 1],
206-
['Senegal', 'Japan', 3],
207-
['Mali', 'China', 5],
208-
['Mali', 'India', 1],
209-
['Mali', 'Japan', 3],
210-
['Morocco', 'China', 5],
211-
['Morocco', 'India', 1],
212-
['Morocco', 'Japan', 3],
167+
...props.atomsRel
168+
// ['Brazil', 'Portugal', 5],
169+
// ['Brazil', 'France', 1],
170+
// ['Brazil', 'Spain', 1],
171+
// ['Brazil', 'England', 1],
172+
// ['Canada', 'Portugal', 1],
173+
// ['Canada', 'France', 5],
174+
// ['Canada', 'England', 1],
175+
// ['Mexico', 'Portugal', 1],
176+
// ['Mexico', 'France', 1],
177+
// ['Mexico', 'Spain', 5],
178+
// ['Mexico', 'England', 1],
179+
// ['USA', 'Portugal', 1],
180+
// ['USA', 'France', 1],
181+
// ['USA', 'Spain', 1],
182+
// ['USA', 'England', 5],
183+
// ['Portugal', 'Angola', 2],
184+
// ['Portugal', 'Senegal', 1],
185+
// ['Portugal', 'Morocco', 1],
186+
// ['Portugal', 'South Africa', 3],
187+
// ['France', 'Angola', 1],
188+
// ['France', 'Senegal', 3],
189+
// ['France', 'Mali', 3],
190+
// ['France', 'Morocco', 3],
191+
// ['France', 'South Africa', 1],
192+
// ['Spain', 'Senegal', 1],
193+
// ['Spain', 'Morocco', 3],
194+
// ['Spain', 'South Africa', 1],
195+
// ['England', 'Angola', 1],
196+
// ['England', 'Senegal', 1],
197+
// ['England', 'Morocco', 2],
198+
// ['England', 'South Africa', 7],
199+
// ['South Africa', 'China', 5],
200+
// ['South Africa', 'India', 1],
201+
// ['South Africa', 'Japan', 3],
202+
// ['Angola', 'China', 5],
203+
// ['Angola', 'India', 1],
204+
// ['Angola', 'Japan', 3],
205+
// ['Senegal', 'China', 5],
206+
// ['Senegal', 'India', 1],
207+
// ['Senegal', 'Japan', 3],
208+
// ['Mali', 'China', 5],
209+
// ['Mali', 'India', 1],
210+
// ['Mali', 'Japan', 3],
211+
// ['Morocco', 'China', 5],
212+
// ['Morocco', 'India', 1],
213+
// ['Morocco', 'Japan', 3],
213214
]}
214215
rootProps={{ 'data-testid': '2' }}
215216
/>

src/app/components/StateRoute.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface StateRouteProps {
3030
state?: string | object;
3131
stateSnaphot?: object;
3232
children?: any[];
33+
AtomsRelationship: any[];
3334
};
3435
hierarchy: object;
3536
snapshots: [];
@@ -64,12 +65,9 @@ const StateRoute = (props: StateRouteProps) => {
6465
}
6566
return <div className="noState">{NO_STATE_MSG}</div>;
6667
};
67-
console.log(3);
68+
6869
const renderAtomsRelationship = () => {
69-
if (hierarchy) {
70-
return <AtomsRelationship hierarchy={hierarchy} />;
71-
}
72-
return <div className="noState">{NO_STATE_MSG}</div>;
70+
return <AtomsRelationship atomsRel={snapshot.AtomsRelationship} />;
7371
};
7472

7573
// the hierarchy gets set on the first click in the page
@@ -129,6 +127,11 @@ const StateRoute = (props: StateRouteProps) => {
129127
<NavLink className="router-link" activeClassName="is-active" to="/map">
130128
Map
131129
</NavLink>
130+
131+
{isRecoil && <NavLink className="router-link" activeClassName="is-active" to="/relationship">
132+
Atoms Relationship
133+
</NavLink>}
134+
132135
<NavLink
133136
className="router-link"
134137
activeClassName="is-active"
@@ -140,6 +143,7 @@ const StateRoute = (props: StateRouteProps) => {
140143
<Switch>
141144
<Route path="/map" render={renderComponentMap} />
142145
<Route path="/history" render={isRecoil ? renderAtomsRelationship: renderHistory} />
146+
<Route path="/relationship" render={renderAtomsRelationship} />
143147
<Route path="/performance" render={renderPerfView} />
144148
<Route path="/" render={renderTree} />
145149
</Switch>

src/backend/linkFiber.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ declare global {
5454
}
5555
}
5656

57+
let isRecoil = false;
5758
let doWork = true;
5859
const circularComponentTable = new Set();
5960
let allAtomsRelationship = [];
@@ -107,11 +108,13 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
107108
const payload = snap.tree.cleanTreeCopy(); // snap.tree.getCopy();
108109
// console.log('here is payload', payload);
109110
// console.log('here is recoil state', window[`$recoilDebugStates`]);
110-
getRecoilState();
111+
isRecoil ? getRecoilState() : ' ' ;
112+
111113
console.log('all atoms state', allAtomsRelationship)
112114
// payload.recoilState = window[`$recoilDebugStates`];
113-
payload.AtomsRelationship = allAtomsRelationship;
114115

116+
isRecoil ? payload.AtomsRelationship = allAtomsRelationship : ' ';
117+
115118
window.postMessage(
116119
{
117120
action: 'recordSnap',
@@ -170,7 +173,7 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
170173
treeBaseDuration,
171174
} = currentFiber;
172175

173-
if (elementType?.name) {
176+
if (elementType?.name && isRecoil) {
174177
console.log('Name here', elementType?.name)
175178
// console.log('Here is the state', memoizedState);
176179
let pointer = memoizedState;
@@ -218,7 +221,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
218221
}
219222

220223
let hooksIndex;
221-
let isRecoil = false;
222224

223225
if (window[`$recoilDebugStates`]) {
224226
isRecoil = true;

0 commit comments

Comments
 (0)