@@ -7,7 +7,12 @@ import TravelContainer from './TravelContainer';
77class MainContainer extends Component {
88 constructor ( ) {
99 super ( ) ;
10- this . state = { snapshots : [ ] } ;
10+ this . state = {
11+ snapshots : [ { state : 'snapshot1' } , { state : 'snapshot2' } , { state : 'snapshot3' } ] ,
12+ snapshotIndex : 0 ,
13+ } ;
14+
15+ this . handleChangeSnapshot = this . handleChangeSnapshot . bind ( this ) ;
1116 }
1217
1318 componentDidMount ( ) {
@@ -22,22 +27,28 @@ class MainContainer extends Component {
2227 // },
2328 // false,
2429 // );
30+ }
2531
26- // MOCK DATA -- FOR TESTING PURPOSES ONLY
27- this . setState ( {
28- snapshots : [ { state : 'snapshot1' } , { state : 'snapshot2' } , { state : 'snapshot3' } ] ,
29- } ) ;
32+ handleChangeSnapshot ( snapshotIndex ) {
33+ console . log ( 'handleChangeSnapshot' , snapshotIndex ) ;
34+ // change snapshotIndex
35+ // snapshotIndex could be changed from either the ActionContainer or the TravelContainer
36+ this . setState ( { snapshotIndex } ) ;
3037 }
3138
3239 render ( ) {
33- const { snapshots } = this . state ;
40+ const { snapshots, snapshotIndex } = this . state ;
3441
3542 return (
3643 < div className = "main-container" >
3744 < HeadContainer />
3845 < div className = "body-container" >
39- < ActionContainer snapshots = { snapshots } />
40- < StateContainer />
46+ < ActionContainer
47+ snapshots = { snapshots }
48+ snapshotIndex = { snapshotIndex }
49+ handleChangeSnapshot = { this . handleChangeSnapshot }
50+ />
51+ < StateContainer snapshot = { snapshots [ snapshotIndex ] } />
4152 </ div >
4253 < TravelContainer />
4354 </ div >
0 commit comments