Instantly share code, notes, and snippets.

@anjum121 /Store.js
Last active Nov 21, 2017

Embed
What would you like to do?
React, Redux, ITunes Music search
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import store, { history } from './store/Store'
import App from './containers/app'
import './theme/App.css'
const target = document.querySelector('#root')
render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div>
<App />
</div>
</ConnectedRouter>
</Provider>,
target
)
{
"name": "itunes-react-redux",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "0.16.2",
"moment": "2.19.1",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-redux": "5.0.6",
"react-router-dom": "4.2.2",
"react-router-redux": "5.0.0-alpha.8",
"react-scripts": "1.0.14",
"redux": "3.7.2",
"redux-thunk": "2.2.0"
},
"scripts": {
"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"node-sass-chokidar": "0.0.3"
}
}
import {createStore, applyMiddleware, compose} from 'redux'
import {routerMiddleware} from 'react-router-redux'
import thunk from 'redux-thunk'
import createHistory from 'history/createBrowserHistory'
import rootReducer from '../modules'
export const history = createHistory()
const initialState = {}
const enhancers = []
const middleware = [
thunk,
routerMiddleware(history)
]
if (process.env.NODE_ENV === 'development') {
const devToolsExtension = window.devToolsExtension
if (typeof devToolsExtension === 'function') {
enhancers.push(devToolsExtension())
}
}
const composedEnhancers = compose(
applyMiddleware(...middleware),
...enhancers
)
const store = createStore(
rootReducer,
initialState,
composedEnhancers
)
export default store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment