const rootEl = document.getElementById(\'root\');
ReactDOM.render(
Another solution is to use a state and lifecycle hooks in the routed component and a search statement in the to
property of the component. The search parameters can later be accessed via
new URLSearchParams()
;
export default class DetailsPage extends Component {
state = {
foo: ''
}
componentDidMount () {
this.parseQueryParams();
}
componentDidUpdate() {
this.parseQueryParams();
}
parseQueryParams () {
const query = new URLSearchParams(this.props.location.search);
for (let param of query.entries()) {
if (this.state.foo!== param[1]) {
this.setState({foo: param[1]});
}
}
}
render() {
return(
{this.state.foo}
)
}
}