-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Add state support to match() #2175
Conversation
Ah, clever ;) Thanks for the PR, @insin! I'm a little uncertain about adding Is it too much to ask people to learn how to use the |
I was going to use I could just create a single history object to reuse across all POST requests, so that works fine for me too if it's going to be the official way to pass state on the server. |
Ya, I agree the API is a bit awkward here. In the end, |
Maybe it would be best to retire Since most of the magic isn't in the actual wrapping of import { createHistory } from 'react-router';
const history = createHistory()
const location = history.createLocation(req.url)
history.match(location, (error, redirectLocation, nextState) => { /* stuff... */ }) Then you can set up your |
Hmm, that's actually a pretty great idea. My only concern is that people are going to start using it client-side, and that's not something we want to encourage. We need to make it extremely clear that the |
|
👍 on having a function for creating a server Perhaps a leaf from React's book: var { DO_NOT_USE_ON_THE_CLIENT_OR_YOU_WILL_BE_FIRED } = require('react-router')
var { createHistory } = DO_NOT_USE_ON_THE_CLIENT_OR_YOU_WILL_BE_FIRED (Or you could include a non-production check which logs a warning if we appear to be running on the client - people really like not having any of those in their console) |
It's perfectly valid to create a memory |
I think I would prefer it if, instead of another option to |
So, e.g. match({
routes,
location: {
pathname: '/the/path',
state: req.body
}
}, callback) |
Looks like a good solution to me. Closing this in favour of whatever comes out of #2186 |
This would make it easy to pass state (e.g.
req.body
) without having to duplicatematch()
's history creation in order to pass a location object in.