File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -21,20 +21,18 @@ class Stocks extends Component {
2121 this . fetches = setInterval ( this . getStocks , 5000 ) ;
2222 }
2323
24- fetchStock = index => {
24+ fetchStock = s => {
2525 let url = '/api/stock' ;
2626 $ . ajax ( {
2727 url : url ,
2828 data : {
29- symbol : this . state . stocks [ index ] . symbol
29+ symbol : s . symbol
3030 } ,
3131 type : 'GET' ,
3232 success : stock => {
3333 let temp = this . state . stocks ;
34- if ( temp [ index ] . symbol === this . state . stocks [ index ] . symbol ) {
35- Object . assign ( temp [ index ] , stock ) ;
36- this . setState ( { stocks : temp } ) ;
37- }
34+ Object . assign ( s , stock ) ;
35+ this . setState ( { stocks : temp } ) ;
3836 } ,
3937 error : ( xhr , status , err ) => {
4038 console . error ( url , status , err . toString ( ) ) ;
@@ -44,7 +42,7 @@ class Stocks extends Component {
4442
4543 getStocks = ( ) => {
4644 for ( let i = 0 ; i < this . state . stocks . length ; i ++ ) {
47- this . fetchStock ( i ) ;
45+ this . fetchStock ( this . state . stocks [ i ] ) ;
4846 }
4947 } ;
5048
You can’t perform that action at this time.
0 commit comments