Skip to content

Commit 3533595

Browse files
committed
mutating state inside component
Signed-off-by: Tathagat Thapliyal <[email protected]>
1 parent 15c5b0b commit 3533595

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/components/Game.js

+9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,28 @@ export default class Game extends React.Component {
1010
history: [
1111
{squares: Array(9).fill(null)}
1212
],
13+
value: 5
1314
}
1415
}
1516

17+
changeState = () => {
18+
this.setState({
19+
value: 6
20+
})
21+
}
22+
1623
someFunction = () => {
1724
return 5
1825
}
1926

2027
render() {
28+
console.log(this.state)
2129
const result = this.someFunction()
2230
return(
2331
<div className= "game">
2432
<div className = "game-board">
2533
<Board value = {result}/>
34+
<button onClick = {() => this.changeState()}>Click Me!</button>
2635
</div>
2736
</div>
2837
)

0 commit comments

Comments
 (0)