Next-routes: Navigate using path and pass params via params props

Created on 12 Jul 2017  路  3Comments  路  Source: fridays/next-routes

Hi @fridays ,
Is it possible to navigate like this?
Router.pushRoute('/search', { id: 1, name: 'abc' });
It looks like that params is not passed when given the path in the first parameter.
Heres the example repo: Example

Most helpful comment

Pass options as the second argument. When resolving by URL, there is no params argument. We need to make this clear in the readme.

All 3 comments

Hi @adrianha you can either use route name & params or a url to resolve:

// routes.js
routes.add('search', '/search/:id/:name')

// Route name and params
Router.pushRoute('search', {id: 1, name: 'abc', more: 'things'})

// Or resolve url
Router.pushRoute('/search/1/abc?more=things')
// Or resolve url
Router.pushRoute('/search/1/abc?more=things')

Hello @fridays ,
If i resolved the url using that method, i found that the third options on pushRoute wont take an effect.
Example:

/** getInitialProps is still called */
Router.pushRoute('/search/1/abc?more=things', {}, { shallow: true });
/** getInitialProps is not called as expected which means the options is working */
Router.pushRoute('search', { id: 1, name: 'abc', more: 'things' }, { shallow: true });

Is there any way to pass the options when i resolve the route using url?
Thanks

Pass options as the second argument. When resolving by URL, there is no params argument. We need to make this clear in the readme.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luisatmaniak picture luisatmaniak  路  6Comments

khankuan picture khankuan  路  7Comments

exogenesys picture exogenesys  路  3Comments

jesstelford picture jesstelford  路  3Comments

davidnguyen179 picture davidnguyen179  路  6Comments