-
Notifications
You must be signed in to change notification settings - Fork 640
Export action creators in namespace. Add go, goBack, goForward #149
Conversation
export const routeActions = { | ||
push, | ||
replace | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably add go
, goBack
, and goForward
? They'll just work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 😄
95822e7
to
2ca9731
Compare
Hmm, the functional tests look to be hard to implement, since |
Can you explain this more? Where does that warning come from? The problem is that Firefox does a full page refresh with |
When using hash history, yes - easy solution is to just add another arg to |
Ok, I guess I'm confused by the comment about Firefox. Chrome behaves differently? Also, it's interesting that in React Router 2.0 you can easily change routes from anywhere: import { browserHistory } from 'react-router'
browserHistory.push(...) IMHO this removes the need to even really use actions to call the history API. But we probably should keep them around for now. |
That only works if you're using those singletons. We're a bit undecided right now on whether or not that's an anti-pattern. I think we've mostly tried to avoid that pattern in our examples. The Chrome/Firefox inconsistency is the Firefox triggers a full page refresh when using |
Ah, thanks for explaining that. Unfortunately that behavior is not specified by w3c, which is why they differ. |
Actually, I'm getting a weirder behavior. When I swap out for Chrome, |
It's probably not fully synchronous or something. I know in the history/router tests, we actually put the assertions in the history listener. What do you think of taking a different approach where we just replace the |
@timdorr think this is ready to be merged? Basically right now we don't test some of the |
I don't think we need integration tests there. Using a mock history and asserting that the right calls are made should be sufficient. |
OK, removed those commits for now. It's all good |
Export action creators in namespace. Add go, goBack, goForward
Sorry (again) to mention this after shipping v2, but I'm iffy on this change. react-redux's // I wish I could do this:
import {push, go} from 'redux-simple-router'
import {myOtherActionCreator} from './myActionCreators'
// these are automatically bound to `dispatch`
export default connect(..., {push, go, myOtherActionCreator}, ...) To avoid passing extra actions to my component, I now have to manually destructure the Also, Would you consider exporting both a scoped object and the individual action creators? (I'm sure there are devs who prefer the scoping.) |
You now get to them via the
routeActions
export.This makes binding just the action creators in your
connect
s really easy: