Skip to content

Commit d8e5dec

Browse files
committed
added tree component rendering
1 parent 5b438e8 commit d8e5dec

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const StateRoute = (props: StateRouteProps) => {
9090
// if true invoke render Tree with snapshot
9191
const renderTree = () => {
9292
if (hierarchy) {
93-
return <Tree snapshot={snapshot} />;
93+
return <Tree snapshot={snapshot} snapshots={snapshots} currLocation={currLocation} />;
9494
}
9595
return <div className='noState'>{NO_STATE_MSG}</div>;
9696
};

src/app/components/StateRoute/Tree.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,27 @@ interface TreeProps {
4040
stateSnaphot?: object;
4141
children?: any[];
4242
};
43+
snapshots?;
44+
currLocation?;
4345
}
4446

4547
const Tree = (props: TreeProps) => {
46-
const { snapshot } = props;
48+
const { snapshot, snapshots, currLocation } = props;
4749
const [store, dispatch] = useStoreContext();
4850

4951
useEffect(() => {
5052
dispatch(setCurrentTabInApp('history'));
5153
}, []);
5254

55+
console.log('props:', props);
56+
// console.log('snapshot:', snapshot);
57+
// console.group('store:', store);
5358
return (
5459
<>
5560
{snapshot && (
5661
<JSONTree
57-
data={snapshot}
62+
data={snapshots[currLocation['index']] || snapshot}
63+
// data={snapshot}
5864
theme={{ extend: colors, tree: () => ({ className: 'json-tree' }) }}
5965
shouldExpandNode={() => true}
6066
getItemString={getItemString}

src/app/containers/MainContainer.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,17 @@ function MainContainer(): JSX.Element {
197197
}
198198

199199
return (
200-
<div className='main-container'>
200+
<div key='main' className='main-container'>
201201
<div id='bodyContainer' className='body-container'>
202202
<ActionContainer
203+
key='action'
203204
actionView={actionView}
204205
setActionView={setActionView}
205206
toggleActionContainer={toggleActionContainer}
206207
/>
207208
{snapshots.length ? handleSplit(split) : null}
208-
<TravelContainer snapshotsLength={snapshots.length} />
209-
<ButtonsContainer />
209+
<TravelContainer key='travel' snapshotsLength={snapshots.length} />
210+
<ButtonsContainer key='button' />
210211
</div>
211212
</div>
212213
);

0 commit comments

Comments
 (0)