12 changed files with 76 additions and 84 deletions
@ -0,0 +1,10 @@ |
|||||
|
export default { |
||||
|
counterValues: { |
||||
|
BTC: { |
||||
|
USD: { |
||||
|
'2018-01-09': 5000e3, |
||||
|
latest: 7000e2, |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
import React from 'react' |
||||
|
import { Provider } from 'react-redux' |
||||
|
import createStore from 'renderer/createStore' |
||||
|
|
||||
|
export default function withStore(state, component) { |
||||
|
const store = createStore({ state }) |
||||
|
return <Provider store={store}>{component}</Provider> |
||||
|
} |
@ -1,20 +1,31 @@ |
|||||
// @flow
|
// @flow
|
||||
|
|
||||
import type { HashHistory } from 'history' |
|
||||
|
|
||||
import { createStore, applyMiddleware, compose } from 'redux' |
import { createStore, applyMiddleware, compose } from 'redux' |
||||
import { routerMiddleware } from 'react-router-redux' |
import { routerMiddleware } from 'react-router-redux' |
||||
import thunk from 'redux-thunk' |
import thunk from 'redux-thunk' |
||||
|
import createHistory from 'history/createHashHistory' |
||||
import db from 'middlewares/db' |
import type { HashHistory } from 'history' |
||||
|
|
||||
import reducers from 'reducers' |
import reducers from 'reducers' |
||||
|
|
||||
export default (history: HashHistory, initialState: any) => { |
type Props = { |
||||
const middlewares = [routerMiddleware(history), thunk, db] |
history: HashHistory, |
||||
|
state?: Object, |
||||
|
history?: any, |
||||
|
dbMiddleware?: Function, |
||||
|
} |
||||
|
|
||||
|
export default ({ state, history, dbMiddleware }: Props) => { |
||||
|
if (!history) { |
||||
|
history = createHistory() |
||||
|
} |
||||
|
const middlewares = [routerMiddleware(history), thunk] |
||||
|
if (dbMiddleware) { |
||||
|
middlewares.push(dbMiddleware) |
||||
|
} |
||||
const enhancers = compose( |
const enhancers = compose( |
||||
applyMiddleware(...middlewares), |
applyMiddleware(...middlewares), |
||||
window.devToolsExtension ? window.devToolsExtension() : f => f, // eslint-disable-line
|
window.devToolsExtension ? window.devToolsExtension() : f => f, // eslint-disable-line
|
||||
) |
) |
||||
return createStore(reducers, initialState, enhancers) |
return createStore(reducers, state, enhancers) |
||||
} |
} |
||||
|
Loading…
Reference in new issue