Skip to content

Instantly share code, notes, and snippets.

@omar-dulaimi
Last active July 15, 2020 06:50
Show Gist options
  • Select an option

  • Save omar-dulaimi/13574f6e84c848927bb4e73971a03a92 to your computer and use it in GitHub Desktop.

Select an option

Save omar-dulaimi/13574f6e84c848927bb4e73971a03a92 to your computer and use it in GitHub Desktop.
Shallow routing Nextjs, undocumented case
this.props.router.push(
`/search?type=${this.state.type}&cat=${this.state.cat}&area=${this.state.area.name}&page=${currentQuery.page}&aid=${this.state.area.id}`,
`/search/${this.state.type}/${this.state.cat}/${this.state.area.name}?page=${currentQuery.page}&aid=${this.state.area.id}`,
{ shallow: true }
);
export default withRouter(connect(mapStateToProps)(SearchPage));
might also need this on your custom server:
server.get('/search/:type/:cat/:area', (req, res) => {
return app.render(req, res, '/search', {
...req.params,
...req.query,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment