merge redux back to index

master
howard 2021-03-28 19:23:24 -07:00
parent 770d8160d2
commit 8a37572dcc
3 changed files with 23 additions and 20 deletions

4
dist/index.html vendored
View File

@ -39,9 +39,9 @@
<div id="react"></div> <div id="react"></div>
<canvas id="c"></canvas> <canvas id="c"></canvas>
<div id="stats"></div> <div id="stats"></div>
<script src="redux.bundle.js"></script> <!-- <script src="redux.bundle.js"></script> -->
<script src="renderer.bundle.js"></script>
<script src="index.bundle.js"></script> <script src="index.bundle.js"></script>
<script src="renderer.bundle.js"></script>
<script src="solver.js"></script> <script src="solver.js"></script>
<script src="lz-string.min.js"></script> <script src="lz-string.min.js"></script>
</body> </body>

View File

@ -3,6 +3,27 @@ import ReactDOM from 'react-dom'
import React from 'react' import React from 'react'
import { Root } from './app.jsx' 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', () => { document.addEventListener('DOMContentLoaded', () => {
ReactDOM.render( ReactDOM.render(
React.createElement(Root, { store: store }, null) React.createElement(Root, { store: store }, null)

View File

@ -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))