Skip to content
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

StaticRouter does not pass on location.state #6112

Closed
Swatinem opened this issue Apr 26, 2018 · 1 comment
Closed

StaticRouter does not pass on location.state #6112

Swatinem opened this issue Apr 26, 2018 · 1 comment

Comments

@Swatinem
Copy link

Version

react-router 4.2.0

Test Case

https://codepen.io/anon/pen/vjXabp?editors=0011

const loc = {
  pathname: "path",
  state: {
    some: "state",
  },
}
const context = {}

const PrintState = ReactRouter.withRouter(
  ({location}) => `${location.pathname}: ${JSON.stringify(location.state)}`)

const out = ReactDOMServer.renderToString(
  <ReactRouter.StaticRouter location={loc} context={context}>
    <PrintState />
  </ReactRouter.StaticRouter>
);
console.log(out)

Steps to reproduce

passing a complete location object to StaticRouter, as described here: https://reacttraining.com/react-router/web/api/StaticRouter/location-object

Expected Behavior

anywhere I use location, for example when using withRouter, the state should be there

Actual Behavior

state is undefined.

@timdorr
Copy link
Member

timdorr commented Apr 26, 2018

This is already fixed with #5722: https://codepen.io/timdorr/pen/depQmv?editors=0011

@timdorr timdorr closed this as completed Apr 26, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants