merge redux back to index
parent
770d8160d2
commit
8a37572dcc
|
@ -39,9 +39,9 @@
|
|||
<div id="react"></div>
|
||||
<canvas id="c"></canvas>
|
||||
<div id="stats"></div>
|
||||
<script src="redux.bundle.js"></script>
|
||||
<script src="renderer.bundle.js"></script>
|
||||
<!-- <script src="redux.bundle.js"></script> -->
|
||||
<script src="index.bundle.js"></script>
|
||||
<script src="renderer.bundle.js"></script>
|
||||
<script src="solver.js"></script>
|
||||
<script src="lz-string.min.js"></script>
|
||||
</body>
|
||||
|
|
21
src/index.js
21
src/index.js
|
@ -3,6 +3,27 @@ import ReactDOM from 'react-dom'
|
|||
import React from 'react'
|
||||
import { Root } from './app.jsx'
|
||||
|
||||
|
||||
import { createStore, applyMiddleware } from 'redux'
|
||||
import logger from 'redux-logger'
|
||||
|
||||
|
||||
|
||||
function reducer(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case 'toggle':
|
||||
return { ...state, toggle: action.payload }
|
||||
case 'rx-new-sketch':
|
||||
return { ...state, sketches: [...state.sketches, action.idx] }
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
window.store = createStore(reducer, {sketches:[]}, applyMiddleware(logger))
|
||||
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
ReactDOM.render(
|
||||
React.createElement(Root, { store: store }, null)
|
||||
|
|
18
src/redux.js
18
src/redux.js
|
@ -1,18 +0,0 @@
|
|||
|
||||
import { createStore, applyMiddleware } from 'redux'
|
||||
import logger from 'redux-logger'
|
||||
|
||||
|
||||
|
||||
function reducer(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case 'toggle':
|
||||
return { ...state, toggle: action.payload }
|
||||
case 'rx-new-sketch':
|
||||
return { ...state, sketches: [...state.sketches, action.idx] }
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
window.store = createStore(reducer, {sketches:[]}, applyMiddleware(logger))
|
Loading…
Reference in New Issue