Commit ee357b9441a7fbb11be1a0d26b0a899624a2b155
general improvements, but stuck on a redux-router error
Michael Williams committed on 11/28/2015, 11:48:37 AMParent: a34eabee8f1d06d0d8190fdc09d638f544d00dca
Files changed
app/client.js | changed |
app/containers/app.js | changed |
app/containers/no-match.js | changed |
app/containers/root.js | changed |
app/containers/todos.js | changed |
app/containers/dev-tools.js | deleted |
app/reducers/index.js | changed |
app/reducers/todos.js | changed |
app/state.js | changed |
app/store.js | changed |
app/components/dev-tools.js | added |
package.json | changed |
app/client.js | ||
---|---|---|
@@ -4,15 +4,15 @@ | ||
4 | 4 | import { reduxReactRouter, routerStateReducer, ReduxRouter } from 'redux-router'; |
5 | 5 | const { Provider } = require('react-redux') |
6 | 6 | const thunk = require('redux-thunk') |
7 | 7 | |
8 | -const createInitialState = require('app/state') | |
8 | +const initialState = require('app/state') | |
9 | 9 | const configureStore = require('app/store') |
10 | 10 | const { getAllTodos } = require('app/actions') |
11 | 11 | const Root = require('app/containers/root') |
12 | 12 | |
13 | 13 | const store = configureStore( |
14 | - createInitialState() | |
14 | + initialState | |
15 | 15 | ) |
16 | 16 | |
17 | 17 | //store.dispatch(getAllTodos()) |
18 | 18 |
app/containers/app.js | ||
---|---|---|
@@ -12,7 +12,6 @@ | ||
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
15 | 15 | module.exports = connect( |
16 | - App, | |
17 | 16 | (state) => { return {} } |
18 | -) | |
17 | +)(App) |
app/containers/no-match.js | ||
---|---|---|
@@ -9,7 +9,6 @@ | ||
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | 12 | module.exports = connect( |
13 | - NoMatch, | |
14 | 13 | (state) => { return {} } |
15 | -) | |
14 | +)(NoMatch) |
app/containers/root.js | ||
---|---|---|
@@ -4,9 +4,9 @@ | ||
4 | 4 | |
5 | 5 | const routes = require('app/routes') |
6 | 6 | |
7 | 7 | if (process.env.NODE_ENV === 'development') { |
8 | - var DevTools = require('app/containers/dev-tools') | |
8 | + var DevTools = require('app/components/dev-tools') | |
9 | 9 | } |
10 | 10 | |
11 | 11 | class Root extends React.Component { |
12 | 12 | render() { |
app/containers/todos.js | ||
---|---|---|
@@ -9,7 +9,6 @@ | ||
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | 12 | module.exports = connect( |
13 | - Todos, | |
14 | 13 | (state) => { return {} } |
15 | -) | |
14 | +)(Todos) |
app/containers/dev-tools.js | ||
---|---|---|
@@ -1,14 +1,0 @@ | ||
1 | -const React = require('react') | |
2 | -const { createDevTools } = require('redux-devtools') | |
3 | -const LogMonitor = require('redux-devtools-log-monitor') | |
4 | -const DockMonitor = require('redux-devtools-dock-monitor') | |
5 | - | |
6 | -const DevTools = createDevTools( | |
7 | - <DockMonitor toggleVisibilityKey='H' | |
8 | - changePositionKey='Q'> | |
9 | - <LogMonitor /> | |
10 | - </DockMonitor> | |
11 | -) | |
12 | - | |
13 | -module.exports = DevTools | |
14 | - |
app/reducers/index.js | ||
---|---|---|
@@ -1,6 +1,8 @@ | ||
1 | 1 | const bulk = require('bulk-require') |
2 | 2 | const { combineReducers } = require('redux') |
3 | +const { routerStateReducer } = require('redux-router') | |
3 | 4 | |
4 | -module.exports = combineReducers( | |
5 | - bulk(__dirname, '*.js') | |
6 | -) | |
5 | +module.exports = combineReducers({ | |
6 | + ...bulk(__dirname, '!(index.js)'), | |
7 | + router: routerStateReducer | |
8 | +}) |
app/reducers/todos.js | ||
---|---|---|
@@ -1,7 +1,9 @@ | ||
1 | +const initialState = require('app/state') | |
2 | + | |
1 | 3 | module.exports = todos |
2 | 4 | |
3 | -function todos (state = {}, action) { | |
5 | +function todos (state = initialState, action) { | |
4 | 6 | switch (action.type) { |
5 | 7 | case 'ADD_TODO': |
6 | 8 | return { |
7 | 9 | ...state, |
app/state.js | ||
---|---|---|
@@ -1,9 +1,3 @@ | ||
1 | -module.exports = createInitialState | |
2 | - | |
3 | -function createInitialState () { | |
4 | - const initialState = { | |
5 | - todos: {} | |
6 | - } | |
7 | - | |
8 | - return initialState | |
1 | +module.exports = { | |
2 | + todos: {} | |
9 | 3 | } |
app/store.js | ||
---|---|---|
@@ -3,49 +3,51 @@ | ||
3 | 3 | const logger = require('redux-logger') |
4 | 4 | const { reduxReactRouter, routerStateReducer, ReduxRouter } = require('redux-router') |
5 | 5 | const { createHistory } = require('history') |
6 | 6 | |
7 | -const rootReducer = require('app/reducers') | |
7 | +const reducer = require('app/reducers') | |
8 | 8 | const routes = require('routes') |
9 | 9 | |
10 | -let storesEnhancers = [] | |
10 | +let storeEnhancers = [] | |
11 | 11 | let middleware = [] |
12 | 12 | |
13 | 13 | middleware.push(thunk) |
14 | 14 | |
15 | 15 | if (process.env.NODE_ENV === 'development') { |
16 | 16 | var { persistState } = require('redux-devtools') |
17 | 17 | |
18 | - var DevTools = require('app/containers/dev-tools') | |
19 | - | |
20 | - middleware.push(logger()) | |
18 | + var DevTools = require('app/components/dev-tools') | |
21 | 19 | } |
22 | 20 | |
23 | -storesEnhancers.push( | |
21 | +storeEnhancers.push( | |
24 | 22 | applyMiddleware(...middleware) |
25 | 23 | ) |
26 | 24 | |
25 | +storeEnhancers.push( | |
26 | + reduxReactRouter({ | |
27 | + routes, createHistory | |
28 | + }) | |
29 | +) | |
30 | + | |
27 | 31 | if (process.env.NODE_ENV === 'development') { |
28 | - storesEnhancers.push(DevTools.instrument()) | |
29 | - storesEnhancers.push(persistState( | |
32 | + | |
33 | + storeEnhancers.push( | |
34 | + applyMiddleware(logger()) | |
35 | + ) | |
36 | + storeEnhancers.push(DevTools.instrument()) | |
37 | + storeEnhancers.push(persistState( | |
30 | 38 | window.location.href.match( |
31 | 39 | /[?&]debug_session=([^&]+)\b/ |
32 | 40 | ) |
33 | 41 | )) |
34 | 42 | } |
35 | 43 | |
36 | -storesEnhancers.push( | |
37 | - reduxReactRouter({ | |
38 | - routes, createHistory | |
39 | - }) | |
40 | -) | |
41 | - | |
42 | -const finalCreateStore = compose( | |
43 | - ...storesEnhancers | |
44 | +const createEnhancedStore = compose( | |
45 | + ...storeEnhancers | |
44 | 46 | )(createStore) |
45 | 47 | |
46 | 48 | function configureStore(initialState) { |
47 | - const store = finalCreateStore(rootReducer, initialState) | |
49 | + const store = createEnhancedStore(reducer, initialState) | |
48 | 50 | |
49 | 51 | if (process.env.NODE_ENV === 'development') { |
50 | 52 | if (module.hot) { |
51 | 53 | module.hot.accept('app/reducers', () => |
app/components/dev-tools.js | ||
---|---|---|
@@ -1,0 +1,13 @@ | ||
1 | +const React = require('react') | |
2 | +const { createDevTools } = require('redux-devtools') | |
3 | +const LogMonitor = require('redux-devtools-log-monitor') | |
4 | +const DockMonitor = require('redux-devtools-dock-monitor') | |
5 | + | |
6 | +const DevTools = createDevTools( | |
7 | + <DockMonitor toggleVisibilityKey='H' | |
8 | + changePositionKey='Q'> | |
9 | + <LogMonitor /> | |
10 | + </DockMonitor> | |
11 | +) | |
12 | + | |
13 | +module.exports = DevTools |
package.json | ||
---|---|---|
@@ -9,9 +9,9 @@ | ||
9 | 9 | "format": "snazzy --format", |
10 | 10 | "test": "(npm run spec & npm run feature)", |
11 | 11 | "spec": "node spec", |
12 | 12 | "feature": "node feature", |
13 | - "dev:client": "budo client --dir assets --serve bundle.js --live -- -dv", | |
13 | + "dev:client": "budo client --dir assets --serve bundle.js --live --pushstate -- -dv", | |
14 | 14 | "dev:assets": "cpx \"app/assets/**/*\" assets -w", |
15 | 15 | "dev:server": "nodemon server", |
16 | 16 | "prod:client": "browserify client -o assets/bundle.js -g uglifyify", |
17 | 17 | "prod:assets": "cpx \"app/assets/**/*\" assets", |
Built with git-ssb-web