File tree 2 files changed +42
-6
lines changed
client/src/components/Binary
2 files changed +42
-6
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Component } from "react" ;
2
2
import { browserHistory } from "react-router" ;
3
3
import axios from "axios" ;
4
+ import EachChoice from "./Each_choice" ;
4
5
5
6
class ChoicesAppear extends Component {
6
7
constructor ( props ) {
@@ -24,12 +25,7 @@ class ChoicesAppear extends Component {
24
25
render ( ) {
25
26
return (
26
27
< div >
27
- { this . state . choices . map ( ( data , index ) => (
28
- < div key = { index } >
29
- < p > { data . Choices_left } </ p >
30
- < p > { data . Choices_right } </ p >
31
- </ div >
32
- ) ) }
28
+ < EachChoice trial_choices = { this . state . choices } />
33
29
</ div >
34
30
) ;
35
31
}
Original file line number Diff line number Diff line change
1
+ import React , { Component } from "react" ;
2
+ import { Link } from "react-router-dom" ;
3
+ import { Route , withRouter } from "react-router-dom" ;
4
+
5
+ class EachChoice extends Component {
6
+ constructor ( props ) {
7
+ super ( props ) ;
8
+ this . state = {
9
+ id : 0
10
+ } ;
11
+ }
12
+
13
+ componentDidMount ( ) {
14
+ let count = 0 ;
15
+ console . log ( "countttt: " , count ) ;
16
+ if ( count === this . props . trial_choices . length ) {
17
+ clearInterval ( this . timer ) ;
18
+ console . log ( "wronggg" ) ;
19
+ }
20
+ this . timer = setInterval ( ( ) => {
21
+ count += 1 ;
22
+ this . setState ( { id : count } ) ;
23
+ console . log ( "interval count: " , count ) ;
24
+ } , 2000 ) ;
25
+ }
26
+
27
+ render ( ) {
28
+ console . log ( this . props . trial_choices . length ) ;
29
+ if ( this . props . trial_choices . length === 0 ) return < h3 > Loading...</ h3 > ;
30
+ return (
31
+ < div >
32
+ < p > { this . props . trial_choices [ this . state . id ] . Choices_left } </ p >
33
+ < p > { this . props . trial_choices [ this . state . id ] . Choices_right } </ p >
34
+ hello
35
+ </ div >
36
+ ) ;
37
+ }
38
+ }
39
+
40
+ export default withRouter ( EachChoice ) ;
You can’t perform that action at this time.
0 commit comments