Skip to content

Commit a396e8a

Browse files
authored
Merge pull request #11 from oslabs-beta/ctxSupport
Ctx support added, Feature section refactor, Nav Bar Refactor
2 parents 5a313fe + c676465 commit a396e8a

File tree

9 files changed

+100
-185
lines changed

9 files changed

+100
-185
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: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
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+
padding: 2px;
13+
}
14+
15+
.tooltipWrapper h2 {
16+
margin-top: 1px;
17+
margin-bottom: 1px;
18+
font-size: small;
19+
font-weight: bolder;
20+
}
21+
22+
.tooltipWrapper p {
23+
margin-top: 1px;
24+
margin-bottom: 1px;
25+
margin-left: 10px;
26+
}
27+
728
/* width */
829
::-webkit-scrollbar {
930
width: 5px;
@@ -36,13 +57,13 @@
3657

3758
// 4. Layout-related sections
3859
@import 'layout/mainContainer', 'layout/bodyContainer', 'layout/actionContainer',
39-
'layout/errorContainer', 'layout/stateContainer', 'layout/travelContainer',
40-
'layout/buttonsContainer', 'layout/headContainer.scss';
60+
'layout/errorContainer', 'layout/stateContainer', 'layout/travelContainer',
61+
'layout/buttonsContainer', 'layout/headContainer.scss';
4162

4263
// 5. Components
4364
@import 'components/buttons', 'components/actionComponent',
44-
'components/jsonTree', 'components/renderingFrequency',
45-
'components/performanceVisx';
65+
'components/jsonTree', 'components/renderingFrequency',
66+
'components/performanceVisx';
4667

4768
// slider component
4869
@import './components/rc-slider', './components/sliderHandle';
@@ -51,4 +72,4 @@
5172
@import './components/d3graph.css';
5273

5374
// diff component
54-
@import './components/diff';
75+
@import './components/diff';

src/backend/linkFiber.ts

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

188+
// if (currentFiber.tag === 10) {
189+
// const queue = [currentFiber];
190+
// while (queue.length > 0) {
191+
// const tempFiber = queue.shift();
192+
// if (tempFiber.tag === 0) console.log(tempFiber);
193+
// if (tempFiber.sibling) {
194+
// queue.push(tempFiber.sibling);
195+
// }
196+
// if (tempFiber.child) {
197+
// queue.push(tempFiber.child);
198+
// }
199+
// }
200+
// }
201+
186202
// check to see if we can get the information we were looking for
187203
if (tag === 5) {
188204
try {
@@ -209,6 +225,7 @@ function createTree(
209225
selfBaseDuration?: number;
210226
treeBaseDuration?: number;
211227
props?: any,
228+
context?: any,
212229
} = {};
213230
let componentFound = false;
214231

@@ -217,6 +234,11 @@ function createTree(
217234
componentData.props = convertDataToString(memoizedProps, null);
218235
}
219236

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+
}
220242
// Check if node is a stateful class component
221243
if (stateNode && stateNode.state && (tag === 0 || tag === 1 || tag === 2)) {
222244
// Save component's state and setState() function to our record for future

src/backend/types/backendTypes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,8 @@ export type Fiber = {
174174
// This value bubbles up during the "complete" phase.
175175
// This field is only set when the enableProfilerTimer flag is enabled.
176176
treeBaseDuration?: number;
177+
178+
dependencies: any;
179+
180+
_debugHookTypes: any;
177181
};

www/src/pages/components/Blogs.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const posts = [
2020
{
2121
title: 'Time-Traveling Through React State',
2222
href: 'https://rxlina.medium.com/time-traveling-through-react-state-with-reactime-9-0-371dbdc99319',
23-
category: { name: 'React', href: '#' },
23+
category: { name: 'React', href: 'https://medium.com/tag/react' },
2424
description:
2525
'Reactime is a Chrome extension and time-travel debugger for React that allows developers to record, track, and visualize state changes. Reactime leverages React’s core reconciliation... ',
2626
date: 'Oct 7, 2021',
@@ -36,21 +36,20 @@ const posts = [
3636
},
3737
},
3838
{
39-
title: 'Open Source DeBugging Tool for React',
40-
href: 'https://betterprogramming.pub/time-traveling-state-with-reactime-6-0-53fdc3ae2a20',
41-
category: { name: 'Better Programming', href: '#' },
42-
description:
43-
'State management is a crucial part of developing efficient and performant React applications. Developers know that managing state can become unmanageable as an application scales... ',
44-
date: 'Oct 21, 2020',
45-
datetime: '2020-10-21',
39+
title: 'What time is it? Reactime!',
40+
href: 'https://medium.com/@robbytiptontol/inter-route-time-travel-with-reactime-d84cd55ec73b',
41+
category: { name: 'React Devtools', href: 'https://medium.com/tag/react-devtools' },
42+
description: 'Reactime is a debugging tool that lets developers take snapshots of an application\’s state data as well as time-travel through these snapshots. The snapshots display React...',
43+
date: 'Jun 16, 2022',
44+
datetime: '2022-06-16',
4645
imageUrl:
4746
'https://images.unsplash.com/photo-1492724441997-5dc865305da7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1679&q=80',
48-
readingTime: '11 min',
47+
readingTime: '9 min',
4948
author: {
50-
name: 'Vincent Nguyen',
51-
href: 'https://medium.com/@CSVince',
49+
name: 'Robby Tipton',
50+
href: 'https://medium.com/@robbytiptontol',
5251
imageUrl:
53-
'https://media-exp1.licdn.com/dms/image/C5603AQEsAdcE-e7kZg/profile-displayphoto-shrink_200_200/0/1604336802983?e=1676505600&v=beta&t=yK3edcZkpG4Yhvr4iavafRs1SBEQgza-4IRJncRV0X4',
52+
'https://miro.medium.com/fit/c/96/96/1*pi-RH2LRvsZA9vLZTvY2mg.jpeg',
5453
},
5554
},
5655
]

www/src/pages/components/FeatureSlider.tsx

Lines changed: 0 additions & 93 deletions
This file was deleted.

www/src/pages/components/FeaturesSection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function FeaturesSection() {
5252
What makes Reactime so great?
5353
</p>
5454
<p className="mx-auto mt-5 max-w-prose text-xl text-gray-500">
55-
Reactime is chock full of features that make your life easier as a developer. From time-travel debugging to state snapshot display, check out how using Reactime will improve your developer experience.
55+
Reactime iscd full of features that make your life easier as a developer. From time-travel debugging to state snapshot display, check out how using Reactime will improve your developer experience.
5656
</p>
5757
<div className="mt-20">
5858
<div className="grid grid-cols-1 gap-12 sm:grid-cols-2 lg:grid-cols-3">

0 commit comments

Comments
 (0)