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

TypeError: Uncaught error: Cannot read property 'apply' of undefined on Beta4 #159

Closed luandro closed 8 years ago

luandro commented 8 years ago
Debug: internal, implementation, error
[1]     TypeError: Uncaught error: Cannot read property 'apply' of undefined
[1]     at Object.createLocation (/Users/luandropvieira/Sites/hapi-universal-redux/node_modules/history/lib/useQueries.js:99:45)
[1]     at /Users/luandropvieira/Sites/hapi-universal-redux/node_modules/redux-router/lib/server.js:52:40
[1]     at /Users/luandropvieira/Sites/hapi-universal-redux/node_modules/redux-router/lib/matchMiddleware.js:21:13
[1]     at /Users/luandropvieira/Sites/hapi-universal-redux/node_modules/redux-router/lib/matchMiddleware.js:27:13
[1]     at Object.dispatch (/Users/luandropvieira/Sites/hapi-universal-redux/node_modules/redux-router/lib/replaceRoutesMiddleware.js:15:16)
[1]     at /Users/luandropvieira/Sites/hapi-universal-redux/src/server.js:93:9
[1]     at /Users/luandropvieira/Sites/hapi-universal-redux/node_modules/hapi/lib/request.js:397:22
[1]     at iterate (/Users/luandropvieira/Sites/hapi-universal-redux/node_modules/hapi/node_modules/items/lib/index.js:36:13)
[1]     at Object.exports.serial (/Users/luandropvieira/Sites/hapi-universal-redux/node_modules/hapi/node_modules/items/lib/index.js:39:9)
[1]     at /Users/luandropvieira/Sites/hapi-universal-redux/node_modules/hapi/lib/request.js:392:15

Got this error on Beta4, it's gone when reverted back to Beta3.

omnidan commented 8 years ago

@luandro can you post a gist with the code that produces this error? :grin:

luandro commented 8 years ago

hope it's readable :8ball: !

I can't get client to match server btw... checksum is always invalid

omnidan commented 8 years ago

@luandro thanks! would be great if you could put it in a repo instead so it's easy to reproduce :sweat_smile: I didn't think it'd be that much :stuck_out_tongue:

luandro commented 8 years ago

@omnidan here's a repo.

git clone -b next https://github.com/luandro/hapi-universal-redux.git
cd hapi-universal-redux

npm install
npm run dev     # to start node server and hot server
npm i redux-router@1.0.0-beta4 # install beta-4 to see the error
npm run dev
luandro commented 8 years ago

Actually I just cloned my own repo, and I get the error even with beta3. I'll close this for now and investigate further.

omnidan commented 8 years ago

@luandro hope you figure it out, feel free to open a new issue if it turns out to be redux-router related :smile:

mattkrick commented 8 years ago

This was caused when I didn't pass in a createHistory function to reduxReactRouter. To fix it: const store = reduxReactRouter({routes, createHistory})(createStore)(rootReducer, initialState);

The lack of a createHistory function should probably throw an error both in reduxReactRouter as well as in the history package if there is no createHistory param passed in (can make a PR if needed, but given the PR backlog, I don't know if it's worth it)

Stack trace:

    at Object.createLocation (/Users/mk/Code/kanbanReactStarter/node_modules/history/lib/useQueries.js:99:45)
    at /Users/mk/Code/kanbanReactStarter/node_modules/redux-router/lib/server.js:52:40
    at /Users/mk/Code/kanbanReactStarter/node_modules/redux-router/lib/matchMiddleware.js:21:13
    at /Users/mk/Code/kanbanReactStarter/node_modules/redux-router/lib/matchMiddleware.js:27:13
    at Object.dispatch (/Users/mk/Code/kanbanReactStarter/node_modules/redux-router/lib/replaceRoutesMiddleware.js:15:16)
    at /Users/mk/Code/kanbanReactStarter/build/webpack:/src/server/server.js:51:9
Scarysize commented 8 years ago

react-router will throw you an error as far as I can see. Will give me: Uncaught TypeError: createHistory is not a function

react-router@1.0.0-rc3

@mattkrick what is your react-router version. Could you test if this is still a issue for you?

mattkrick commented 8 years ago

I just checked again, still doesn't throw, react-router isn't part of the stack trace. "react-router": "^1.0.0-rc3", "redux-router": "^1.0.0-beta4",

Scarysize commented 8 years ago

Can you throw together a gist or give me repo to reproduce the error?

mattkrick commented 8 years ago

Sure thing: https://gist.github.com/mattkrick/08dff8474882f01993fb

After line 3 it shouldn't matter since it breaks at creating the store