Commit 8f60cd66 authored by Alexander Kotov's avatar Alexander Kotov

show moves count

parent c2c5b0f3
......@@ -2,11 +2,13 @@ import React, { Component } from 'react'
import './App.css'
import Board from './components/Board/Board';
import Toolbar from './components/Toolbar/Toolbar';
class App extends Component {
render() {
return (
<div>
<Toolbar></Toolbar>
<Board></Board>
</div>
);
......
import React, { Component } from 'react'
import store from '../../store';
const mapStoreState = () => {
let { moves } = store.getState()
return { moves }
}
export default class Toolbar extends Component {
state = mapStoreState()
updateState = () => {
this.setState(mapStoreState())
}
componentDidMount() {
store.subscribe(this.updateState)
}
render() {
return (
<div>
Moves: {this.state.moves}
</div>
)
}
}
......@@ -2,7 +2,9 @@ import { createStore } from 'redux'
import rootReducer from './reducers'
export default createStore(
const store = createStore(
rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
export default store
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment