1- import React , { useContext , Component } from 'react' ;
1+ import React , { Component } from 'react' ;
22import { createGlobalStyle } from 'styled-components' ;
33
44// containers
@@ -48,7 +48,7 @@ class App extends Component {
4848 } ;
4949
5050 this . portToExtension = null ;
51-
51+
5252 this . addActionToView = this . addActionToView . bind ( this ) ;
5353 this . toTheFuture = this . toTheFuture . bind ( this ) ;
5454 this . toThePast = this . toThePast . bind ( this ) ;
@@ -82,6 +82,7 @@ class App extends Component {
8282 } ) ) ;
8383 } ) ;
8484 } ) ;
85+ }
8586
8687 // functionality to change 'play' button to 'stop'
8788 setIsPlaying ( ) {
@@ -120,16 +121,19 @@ class App extends Component {
120121
121122 actionInPlay ( ) {
122123 let { isPlayingIndex } = this . state ;
123- if ( isPlayingIndex >= this . state . data . length - 1 ) isPlayingIndex = 0 ;
124+ const { isPlaying, data } = this . state ;
125+
126+ if ( isPlayingIndex >= data . length - 1 ) isPlayingIndex = 0 ;
124127
125128 this . setState ( { isPlayingIndex : isPlayingIndex + 1 } ) ;
126- const { id, action, state } = this . state . data [ isPlayingIndex + 1 ] ;
129+ const { id, action, state } = data [ isPlayingIndex + 1 ] ;
130+ this . toTheFuture ( ) ;
127131
128132 setTimeout ( ( ) => {
129133 this . setState ( ( prev , props ) => {
130134 return { ...prev , id, action, state } ;
131135 } ) ;
132- if ( this . state . isPlaying && isPlayingIndex + 1 < this . state . data . length - 1 ) {
136+ if ( isPlaying && isPlayingIndex + 1 < data . length - 1 ) {
133137 this . actionInPlay ( ) ;
134138 } else {
135139 this . setState ( { isPlaying : false } ) ;
@@ -153,12 +157,12 @@ class App extends Component {
153157 // filter search bar results
154158 searchChange ( e ) {
155159 const { data } = this . state ;
156-
160+
157161 // grab user entry from filter bar
158162 const compareSearchValue = e . target . value ;
159163
160164 // set state with compare value
161- this . setState ( { searchField : compareSearchValue } )
165+ this . setState ( { searchField : compareSearchValue } ) ;
162166
163167 // match results from our filter entry to data
164168 const actions = data . filter ( function ( item ) {
@@ -200,7 +204,6 @@ class App extends Component {
200204 }
201205
202206 render ( ) {
203- console . log ( this . state . isPlayingIndex ) ;
204207 const {
205208 action,
206209 id,
@@ -254,4 +257,4 @@ class App extends Component {
254257 }
255258}
256259
257- export default App ;
260+ export default App ;
0 commit comments