From 8a37572dcc74bc8999231b767cea9404db2bf5ff Mon Sep 17 00:00:00 2001 From: howard Date: Sun, 28 Mar 2021 19:23:24 -0700 Subject: [PATCH] merge redux back to index --- dist/index.html | 4 ++-- src/index.js | 21 +++++++++++++++++++++ src/redux.js | 18 ------------------ 3 files changed, 23 insertions(+), 20 deletions(-) delete mode 100644 src/redux.js diff --git a/dist/index.html b/dist/index.html index a15d4e1..b62c7f4 100644 --- a/dist/index.html +++ b/dist/index.html @@ -39,9 +39,9 @@
- - + + diff --git a/src/index.js b/src/index.js index 7555e96..6758faa 100644 --- a/src/index.js +++ b/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) diff --git a/src/redux.js b/src/redux.js deleted file mode 100644 index 1dd0603..0000000 --- a/src/redux.js +++ /dev/null @@ -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))