Skip to content

Commit b4dcb3e

Browse files
committed
pulled from dev
2 parents 6595bed + e86d568 commit b4dcb3e

File tree

4 files changed

+61
-21
lines changed

4 files changed

+61
-21
lines changed

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,19 @@ export default function ComponentMap({
153153
return propsFormat;
154154
};
155155

156+
const formatContext = data => {
157+
const propsFormat = [];
158+
const nestedObj = [];
159+
for (const key in data) {
160+
propsFormat.push(
161+
<p className="stateprops">
162+
{`${key}: ${data[key]}`}
163+
</p>,
164+
);
165+
}
166+
return propsFormat;
167+
};
168+
156169
const formatState = state => {
157170
if (state === 'stateless') return ['stateless'];
158171
return ['stateful'];
@@ -378,10 +391,15 @@ export default function ComponentMap({
378391
{formatState(tooltipData.state)}
379392
</div>
380393
<div style={React.scrollStyle}>
381-
<div className="props">
382-
Props:
394+
<div className="tooltipWrapper">
395+
<h2>Props:</h2>
383396
{formatProps(tooltipData.componentData.props)}
384397
</div>
398+
{tooltipData.componentData.context &&
399+
<div className="tooltipWrapper">
400+
<h2>Context:</h2>
401+
{formatContext(tooltipData.componentData.context)}
402+
</div>}
385403
</div>
386404
</div>
387405
</TooltipInPortal>

src/app/styles/main.scss

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
@charset 'UTF-8';
22
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
3+
34
* {
45
font-family: 'Roboto', sans-serif;
56
}
67

8+
.tooltipWrapper {
9+
background-color: #505050;
10+
color: rgb(216, 216, 216);
11+
margin-top: 3px;
12+
margin-bottom: 3px;
13+
padding: 2px;
14+
}
15+
16+
.tooltipWrapper h2 {
17+
margin-top: 1px;
18+
margin-bottom: 1px;
19+
margin-left: 1px;
20+
font-size: small;
21+
font-weight: bolder;
22+
}
23+
24+
.tooltipWrapper p {
25+
margin-top: 1px;
26+
margin-bottom: 1px;
27+
margin-left: 10px;
28+
margin-right: 3px;
29+
}
30+
731
/* width */
832
::-webkit-scrollbar {
933
width: 5px;
@@ -36,13 +60,13 @@
3660

3761
// 4. Layout-related sections
3862
@import 'layout/mainContainer', 'layout/bodyContainer', 'layout/actionContainer',
39-
'layout/errorContainer', 'layout/stateContainer', 'layout/travelContainer',
40-
'layout/buttonsContainer', 'layout/headContainer.scss';
63+
'layout/errorContainer', 'layout/stateContainer', 'layout/travelContainer',
64+
'layout/buttonsContainer', 'layout/headContainer.scss';
4165

4266
// 5. Components
4367
@import 'components/buttons', 'components/actionComponent',
44-
'components/jsonTree', 'components/renderingFrequency',
45-
'components/performanceVisx';
68+
'components/jsonTree', 'components/renderingFrequency',
69+
'components/performanceVisx';
4670

4771
// slider component
4872
@import './components/rc-slider', './components/sliderHandle';
@@ -51,4 +75,4 @@
5175
@import './components/d3graph.css';
5276

5377
// diff component
54-
@import './components/diff';
78+
@import './components/diff';

src/backend/linkFiber.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,34 +181,24 @@ function createTree(
181181
actualStartTime,
182182
selfBaseDuration,
183183
treeBaseDuration,
184+
dependencies,
185+
_debugHookTypes,
184186
} = currentFiber;
185187

186-
187188
// if (currentFiber.tag === 10) {
188189
// const queue = [currentFiber];
189-
// const result = [];
190190
// while (queue.length > 0) {
191191
// const tempFiber = queue.shift();
192-
// if (tempFiber.tag === 0 && tempFiber._debugHookTypes) result.push(tempFiber);
192+
// if (tempFiber.tag === 0) console.log(tempFiber);
193193
// if (tempFiber.sibling) {
194194
// queue.push(tempFiber.sibling);
195195
// }
196196
// if (tempFiber.child) {
197197
// queue.push(tempFiber.child);
198198
// }
199199
// }
200-
// console.log('test', result);
201200
// }
202201

203-
// if(currentFiber.tag === 10) {
204-
// let stack = [currentFiber];
205-
206-
// while(stack > 0) {
207-
// let node = stack.pop();
208-
209-
210-
// }
211-
// }
212202
// check to see if we can get the information we were looking for
213203
if (tag === 5) {
214204
try {
@@ -235,6 +225,7 @@ function createTree(
235225
selfBaseDuration?: number;
236226
treeBaseDuration?: number;
237227
props?: any,
228+
context?: any,
238229
} = {};
239230
let componentFound = false;
240231

@@ -243,6 +234,11 @@ function createTree(
243234
componentData.props = convertDataToString(memoizedProps, null);
244235
}
245236

237+
// if the component uses the useContext hook, we want to grab the co text object and add it to the componentData object for that fiber
238+
if (tag === 0 && _debugHookTypes) {
239+
componentData.context = convertDataToString(dependencies?.firstContext?.memoizedValue, null);
240+
console.log(convertDataToString(componentData.context, null), componentData.context);
241+
}
246242
// Check if node is a stateful class component
247243
if (stateNode && stateNode.state && (tag === 0 || tag === 1 || tag === 2)) {
248244
// Save component's state and setState() function to our record for future

src/backend/types/backendTypes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,7 @@ export type Fiber = {
175175
// This field is only set when the enableProfilerTimer flag is enabled.
176176
treeBaseDuration?: number;
177177

178-
_debugHookTypes?: string[] | null;
178+
dependencies: any;
179+
180+
_debugHookTypes: any;
179181
};

0 commit comments

Comments
 (0)