Skip to content

Commit 1c36c7d

Browse files
authored
Merge pull request #8 from oslabs-beta/backend
Backend
2 parents 0ecb4e3 + 6b58483 commit 1c36c7d

File tree

5 files changed

+165
-143
lines changed

5 files changed

+165
-143
lines changed

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

Lines changed: 17 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -20,71 +20,6 @@ import getLinkComponent from './getLinkComponent';
2020
import { toggleExpanded, setCurrentTabInApp } from '../../../actions/actions';
2121
import { useStoreContext } from '../../../store';
2222

23-
// const exclude = [
24-
// 'childExpirationTime',
25-
// 'staticContext',
26-
// '_debugSource',
27-
// 'actualDuration',
28-
// 'actualStartTime',
29-
// 'treeBaseDuration',
30-
// '_debugID',
31-
// '_debugIsCurrentlyTiming',
32-
// 'selfBaseDuration',
33-
// 'expirationTime',
34-
// 'effectTag',
35-
// 'alternate',
36-
// '_owner',
37-
// '_store',
38-
// 'get key',
39-
// 'ref',
40-
// '_self',
41-
// '_source',
42-
// 'firstBaseUpdate',
43-
// 'updateQueue',
44-
// 'lastBaseUpdate',
45-
// 'shared',
46-
// 'responders',
47-
// 'pending',
48-
// 'lanes',
49-
// 'childLanes',
50-
// 'effects',
51-
// 'memoizedState',
52-
// 'pendingProps',
53-
// 'lastEffect',
54-
// 'firstEffect',
55-
// 'tag',
56-
// 'baseState',
57-
// 'baseQueue',
58-
// 'dependencies',
59-
// 'Consumer',
60-
// 'context',
61-
// '_currentRenderer',
62-
// '_currentRenderer2',
63-
// 'mode',
64-
// 'flags',
65-
// 'nextEffect',
66-
// 'sibling',
67-
// 'create',
68-
// 'deps',
69-
// 'next',
70-
// 'destroy',
71-
// 'parentSub',
72-
// 'child',
73-
// 'key',
74-
// 'return',
75-
// 'children',
76-
// '$$typeof',
77-
// '_threadCount',
78-
// '_calculateChangedBits',
79-
// '_currentValue',
80-
// '_currentValue2',
81-
// 'Provider',
82-
// '_context',
83-
// 'stateNode',
84-
// 'elementType',
85-
// 'type',
86-
// ];
87-
8823
const defaultMargin = {
8924
top: 30,
9025
left: 30,
@@ -187,38 +122,15 @@ export default function ComponentMap({
187122
return `${renderTime} ms `;
188123
};
189124

190-
const formatProps = (data) => {
191-
console.log('ComponentMap', { data });
192-
const propsFormat = [];
193-
// const nestedObj = [];
194-
for (const key in data) {
195-
if (
196-
// data[key] !== 'reactFiber' &&
197-
typeof data[key] !== 'object'
198-
// exclude.includes(key) !== true
199-
) {
200-
propsFormat.push(<p className='stateprops'>{`${key}: ${data[key]}`}</p>);
201-
}
202-
// else if (
203-
// data[key] !== 'reactFiber' &&
204-
// typeof data[key] === 'object'
205-
// exclude.includes(key) !== true
206-
// ) {
207-
// const result = formatProps(data[key]);
208-
// nestedObj.push(result);
209-
// }
210-
}
211-
// if (nestedObj) {
212-
// propsFormat.push(nestedObj);
213-
// }
214-
if (propsFormat.length) return propsFormat;
215-
};
216-
217-
const formatContext = (data) => {
125+
const formatData = (data, type) => {
218126
const contextFormat = [];
219127
for (const key in data) {
220128
// Suggestion: update the front end to display as a list if we have object
221-
contextFormat.push(<p className='statecontext'>{`${key}: ${data[key]}`}</p>);
129+
let inputData = data[key];
130+
if (inputData !== null && typeof inputData === 'object') {
131+
inputData = JSON.stringify(inputData);
132+
}
133+
contextFormat.push(<p className={`${type}-item`}>{`${key}: ${inputData}`}</p>);
222134
}
223135
return contextFormat;
224136
};
@@ -437,14 +349,18 @@ export default function ComponentMap({
437349
<div style={React.scrollStyle}>
438350
<div className='tooltipWrapper'>
439351
<h2>Props:</h2>
440-
{formatProps(tooltipData.componentData.props)}
352+
{formatData(tooltipData.componentData.props, 'props')}
353+
</div>
354+
355+
<div className='tooltipWrapper'>
356+
<h2>Initial Context:</h2>
357+
{formatData(tooltipData.componentData.context, 'context')}
358+
</div>
359+
360+
<div className='tooltipWrapper'>
361+
<h2>State:</h2>
362+
{formatData(tooltipData.componentData.state, 'state')}
441363
</div>
442-
{tooltipData.componentData.context && (
443-
<div className='tooltipWrapper'>
444-
<h2>Context:</h2>
445-
{formatContext(tooltipData.componentData.context)}
446-
</div>
447-
)}
448364
</div>
449365
</div>
450366
</TooltipInPortal>

src/backend/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const timeJump = timeJumpStart(mode);
3333
window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
3434
switch (action) {
3535
case 'jumpToSnap':
36+
console.log('Index ts', { payload });
3637
timeJump(payload, true); // * This sets state with given payload
3738
break;
3839

0 commit comments

Comments
 (0)