In react-router v3 I could access it with props.location.query.foo
(if the current location was ?foo=bar
)
In react-router-dom@4.0.0>
Using third party package is overkill to simple solutions
componentDidMount() {
const query = new URLSearchParams(
this.props.location.search
);
let data= {};
for (let params of query.entries()) {
data[params[0]] = +params[1];
}
this.setState({ urldata: data});
}
this will simply convert URL data into object.