A collection of navigation-related functions for handling query parameter objects, serializing query parameters, updating query parameters, and triggering path changes.
## Installation
Install the module
```bash
npm install @woocommerce/navigation --save
```
## Usage
### history
A single history object used to perform path changes. This needs to be passed into ReactRouter to use the other path functions from this library.
```jsx
import { history } from '@woocommerce/navigation';
render() {
return (
<Routerhistory={history}>
…
</Router>
);
}
```
### getAdminLink(path) ⇒ <code>String</code>
Returns a string with the site's wp-admin URL appended. JS version of `admin_url`. This relies on a global object `wcSettings` with a property `adminUrl` set.
**Returns**: <code>String</code> - Full admin URL.
| Param | Type | Description |
| --- | --- | --- |
| path | <code>String</code> | Relative path. |
### getPath() ⇒ <code>String</code>
Get the current path from history.
**Returns**: <code>String</code> - Current path.
### stringifyQuery(query) ⇒ <code>String</code>
Converts a query object to a query string.
**Returns**: <code>String</code> - Query string.
| Param | Type | Description |
| --- | --- | --- |
| query | <code>Object</code> | parameters to be converted. |
Get the default option's value from the configuration object for a given filter. The first option is used as default if no <code>defaultOption</code> is provided.
**Returns**: <code>string</code> \| <code>undefined</code> - - the value of the default option.
| Param | Type | Description |
| --- | --- | --- |
| config | <code>object</code> | a filter config object. |