File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1
1
import * as React from "react" ;
2
2
import PropTypes from "prop-types" ;
3
3
import { close } from "./icons" ;
4
+ import Results from "./Results" ;
4
5
5
6
function Instructions ( ) {
6
7
return (
@@ -102,6 +103,7 @@ export default class Battle extends React.Component {
102
103
this . state = {
103
104
playerOne : null ,
104
105
playerTwo : null ,
106
+ battle : false ,
105
107
} ;
106
108
107
109
this . handleSubmit = this . handleSubmit . bind ( this ) ;
@@ -118,14 +120,23 @@ export default class Battle extends React.Component {
118
120
} ) ;
119
121
}
120
122
render ( ) {
121
- const { playerOne, playerTwo } = this . state ;
123
+ const { playerOne, playerTwo, battle } = this . state ;
122
124
const disabled = ! playerOne || ! playerTwo ;
123
125
126
+ if ( battle === true ) {
127
+ return < Results playerOne = { playerOne } playerTwo = { playerTwo } /> ;
128
+ }
129
+
124
130
return (
125
131
< main className = "stack main-stack animate-in" >
126
132
< div className = "split" >
127
133
< h1 > Players</ h1 >
128
- < button className = { `btn primary ${ disabled ? "disabled" : "" } ` } >
134
+ < button
135
+ onClick = { ( ) => {
136
+ this . setState ( { battle : true } ) ;
137
+ } }
138
+ className = { `btn primary ${ disabled ? "disabled" : "" } ` }
139
+ >
129
140
Battle
130
141
</ button >
131
142
</ div >
Original file line number Diff line number Diff line change
1
+ import * as React from "react" ;
2
+
3
+ export default class Results extends React . Component {
4
+ render ( ) {
5
+ return (
6
+ < div >
7
+ Results
8
+ < pre > { JSON . stringify ( this . props , null , 2 ) } </ pre >
9
+ </ div >
10
+ ) ;
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments