-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
integrate redux-react-router #41
Comments
I am watching that project closely, but I'm waiting for it to gain a tad more stability. This will happen eventually, and I welcome any other attempts by @athibaud or others. |
Using our own actions/reducers we can hang on to the history functions in react router to achieve the desired result, and it will also work when hydrating initial location from the server.. This is the section inside the universalRouter that does majority of the work.
The Router Reducer
The Action
This will track all router changes and then allow rollback without tracking as new locations in the redux dev tools. Also does not create history in the browser when rolling back in time with redux. |
Hey guys i seem to have integrated redux-react-router in my project which is a clone of this :P it has some problems as stated on redux-react-router's docs like complaining about owner-based and parent-based contexts being different and some other stuff but otherwise works fine |
@erikras I don't think so. Here's what i did to investigate: @connect(state => ({router: state.router}))
export default class Home {
render() {
console.log(this.props.router); and it shows the proper query params in the console when the server renders the DefaultRoute |
Interesting. I was using Thanks for the update. |
np :) |
@quirinpa No, the problem is that the query parameters aren't present when it's time to I just tried with |
@erikras oh i see.. Shame. Also i've experimented with code splitting. I'm not sure to what extent but the page works, as long as you hot reload at least once. Yes... If you don't webpack throws an error "cannot read property call of undefined" because webpack tries to call a module that is not yet defined, i've tried at least 2 require polyfills (hacky stuff) and still no luck. Im missing something in regards to that aswell. Also i've read gaeron say somewhere that actions wouldn't be atributed to the component at start. Sorry if i kept your hopes up. :( |
@erikras but more on the topic of redux-react-router i just did: export default function universalRouter(location, history, store) {
if (__SERVER__)
store.dispatch({type: '@@reduxReactRouter/locationDidChange', payload: location }); and it seems to fix that problem, i think |
This task deserves revisiting after React 0.14 comes out. If it has come out already and you are reading this, leave a comment. |
I was thinking about this and I might be completely off-base, but: One possibility to solve this for React 0.13 is to send an action with the router at the start of the app, and then the redux-router middleware should catch and use that instead of relying on context. Also I am wondering what the best way would be to turn URL state into app state, for example if you have the url "mails/5", it would be nice if you have an appstate reducer that converts that into currentComponent "MailBox" and currentMail 5 instead of relying on the MailBox component to read the params and convert the URL itself. Not sure. |
|
@erikras http://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html has been released |
Is there an update using 0.14? |
related discussions on rackt/redux/pull/714 and reduxjs/redux#805 |
@erikras Close this. |
i tried so myself but to no avail.
has to be a context problem because i get
Warning: Failed Context Types: Required context 'store' was not specified in 'Connector'. Check the render method of 'Connector(AppContainer)'.
The text was updated successfully, but these errors were encountered: