React-starter-kit: How do we get query parameters in router?

Created on 12 Dec 2016  路  1Comment  路  Source: kriasoft/react-starter-kit

for example in this route, how would I get :placeSlug ?

path: '/place/:placeSlug',

Most helpful comment

https://github.com/kriasoft/universal-router/blob/master/docs/api.md#url-parameters

const route = {
  path: '/path/:any',                 // example url: '/path/hello?the=query'
  action({ path, params, query }) {
    console.log(path);                // => '/path/hello'
    console.log(params);              // => { any: 'hello' }
    console.log(query);               // => { the: 'query' }
  }
}

>All comments

https://github.com/kriasoft/universal-router/blob/master/docs/api.md#url-parameters

const route = {
  path: '/path/:any',                 // example url: '/path/hello?the=query'
  action({ path, params, query }) {
    console.log(path);                // => '/path/hello'
    console.log(params);              // => { any: 'hello' }
    console.log(query);               // => { the: 'query' }
  }
}
Was this page helpful?
0 / 5 - 0 ratings