Skip to content

Commit

Permalink
CR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrdyn committed Dec 18, 2023
1 parent a5c6ed8 commit 8bf3070
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/kbn-router-utils/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# @kbn/router-utils

This package provides util functions when working with the router.

## getRouterLinkProps

Useful to generate link component properties for HTML elements, this link properties will allow them to behave as native links and handle events such as open in a new tab, or client-side navigation without refreshing the whole page.

### Example

We want a button to both navigate to Discover client-side or open on a new window.

```ts
const DiscoverLink = (discoverLinkParams) => {
const discoverUrl = discover.locator?.getRedirectUrl(discoverLinkParams);

const navigateToDiscover = () => {
discover.locator?.navigate(discoverLinkParams);
};

const linkProps = getRouterLinkProps({
href: discoverUrl,
onClick: navigateToDiscover,
});

return (
<>
<EuiButton {...linkProps}>
{discoverLinkTitle}
</EuiButton>
</>
);
};
```

0 comments on commit 8bf3070

Please sign in to comment.