Skip to content

Commit 79aa9bd

Browse files
committed
converted buttons container to context
1 parent 9832211 commit 79aa9bd

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

src/app/containers/ButtonsContainer.jsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useContext } from 'react';
2-
import PropTypes from 'prop-types';
32

43
import {
54
importSnapshots, toggleMode,
@@ -36,9 +35,8 @@ function importHandler(dispatch) {
3635
fileUpload.click();
3736
}
3837

39-
function ButtonsContainer(props) {
40-
const { snapshots, mode: { paused, locked, persist }, dispatch } = props;
41-
// const [{ snapshots, mode: { paused, locked, persist } }, dispatch] = useContext(StoreContext);
38+
function ButtonsContainer() {
39+
const [{ snapshots, mode: { paused, locked, persist } }, dispatch] = useContext(StoreContext);
4240
return (
4341
<div className="buttons-container">
4442
<button className="pause-button" type="button" onClick={() => dispatch(toggleMode('paused'))}>
@@ -60,16 +58,4 @@ function ButtonsContainer(props) {
6058
);
6159
}
6260

63-
ButtonsContainer.propTypes = {
64-
dispatch: PropTypes.func.isRequired,
65-
snapshots: PropTypes.arrayOf(
66-
PropTypes.object,
67-
).isRequired,
68-
mode: PropTypes.shape({
69-
paused: PropTypes.bool,
70-
locked: PropTypes.bool,
71-
persist: PropTypes.bool,
72-
}).isRequired,
73-
};
74-
7561
export default ButtonsContainer;

src/app/containers/MainContainer.jsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,31 @@ function MainContainer() {
7070
// if viewIndex is -1, then use the sliderIndex instead
7171
const snapshotView = (viewIndex === -1) ? snapshots[sliderIndex] : snapshots[viewIndex];
7272
return (
73-
// <StoreContext.Provider value={[mainState, dispatch]}>
74-
<div className="main-container">
75-
<HeadContainer />
76-
<div className="body-container">
77-
<ActionContainer
78-
snapshots={snapshots}
79-
sliderIndex={sliderIndex}
80-
viewIndex={viewIndex}
81-
dispatch={dispatch}
82-
/>
83-
{(snapshots.length) ? <StateContainer snapshot={snapshotView} /> : null}
84-
<TravelContainer
85-
snapshotsLength={snapshots.length}
86-
sliderIndex={sliderIndex}
87-
playing={playing}
88-
dispatch={dispatch}
89-
/>
90-
<ButtonsContainer
91-
mode={mode}
92-
dispatch={dispatch}
93-
snapshots={mainState.snapshots}
94-
/>
73+
<StoreContext.Provider value={[mainState, dispatch]}>
74+
<div className="main-container">
75+
<HeadContainer />
76+
<div className="body-container">
77+
<ActionContainer
78+
snapshots={snapshots}
79+
sliderIndex={sliderIndex}
80+
viewIndex={viewIndex}
81+
dispatch={dispatch}
82+
/>
83+
{(snapshots.length) ? <StateContainer snapshot={snapshotView} /> : null}
84+
<TravelContainer
85+
snapshotsLength={snapshots.length}
86+
sliderIndex={sliderIndex}
87+
playing={playing}
88+
dispatch={dispatch}
89+
/>
90+
<ButtonsContainer
91+
mode={mode}
92+
dispatch={dispatch}
93+
snapshots={mainState.snapshots}
94+
/>
95+
</div>
9596
</div>
96-
</div>
97-
// </StoreContext.Provider>
97+
</StoreContext.Provider>
9898
);
9999
}
100100

0 commit comments

Comments
 (0)