acdlite / redux-router

Redux bindings for React Router – keep your router state inside your Redux store
MIT License
2.3k stars 200 forks source link

error with 'history' #41

Closed pdeva closed 9 years ago

pdeva commented 9 years ago

I have code like this (in typescript)

import {createHistory} from 'history/lib/createBrowserHistory';

let rootReducer =  combineReducers({ postsByReddit, router: reduxRouter.routerStateReducer });

export const reduxStore = compose(applyMiddleware(thunkMiddleware), reduxRouter.reduxReactRouter({ routes: routesFile.routes, createHistory: createHistory}) )(createStore)(rootReducer)

However, this fails with msg and no routes are loaded.

Uncaught TypeError: Cannot read property 'listen' of undefined

This is the code that triggers this:

2015-09-13_1131

This is how i render my router currently:

React.render((
    <reactRedux.Provider store={reduxSetp.reduxStore}>
      {()=><ReduxRouter/>}
    </reactRedux.Provider>
) , document.getElementById('content'));

This only happens when i use redux-react-router, not with normal usage of react-router.

What am i doing wrong?

pdeva commented 9 years ago

ok it turns out the import line should be:

import {createHistory} from 'history;

instead of

import {createHistory} from 'history/lib/createBrowserHistory';

This also means the example on Readme.md is incorrect.