Skip to content

Instantly share code, notes, and snippets.

@ashleyconnor
Created February 14, 2017 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashleyconnor/81e672599902ea355bb5695a41a41e3d to your computer and use it in GitHub Desktop.
Save ashleyconnor/81e672599902ea355bb5695a41a41e3d to your computer and use it in GitHub Desktop.
// deps
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-redux": "^5.0.2",
"react-router": "next",
"react-router-redux": "next",
"redux": "^3.6.0",
"redux-logger": "^2.8.1"
// index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { browserHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import configureStore from './store';
import { App } from './containers/App';
const store = configureStore(browserHistory)
const history = syncHistoryWithStore(browserHistory, store)
const target = document.getElementById('root')
const node = <App routerHistory={history} store={store} />;
ReactDOM.render(node, target);
// store
import { createStore, applyMiddleware } from 'redux';
import { routerMiddleware } from 'react-router-redux';
import createLogger from 'redux-logger';
import reducers from '../reducers';
const loggerMiddleware = createLogger({
level: 'info',
collapsed: true
});
export default function configureStore(browserHistory) {
const reduxRouterMiddleware = routerMiddleware(browserHistory);
const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware, loggerMiddleware)(createStore);
return createStoreWithMiddleware(reducers);
}
// reducers
import { combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux';
export default combineReducers({
routing: routerReducer
})
//error
Uncaught TypeError: Cannot read property 'listen' of undefined
at syncHistoryWithStore (sync.js:102)
at Object.<anonymous> (index.js:10)
at __webpack_require__ (bootstrap cf245a9…:555)
at fn (bootstrap cf245a9…:86)
at Object.<anonymous> (bootstrap cf245a9…:578)
at __webpack_require__ (bootstrap cf245a9…:555)
at bootstrap cf245a9…:578
at bootstrap cf245a9…:578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment