Skip to content

Commit

Permalink
Update PrivateRoute stories
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Apr 19, 2021
1 parent 7fe997e commit eb6e5ff
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/components/PrivateRoute/PrivateRoute.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
import PrivateRoute from "../PrivateRoute";

The PrivateRoute wraps [React Router](https://reactrouter.com/)'s [Route component](https://reactrouter.com/web/api/Route) and checks for authentication using [AuthProvider](/?path=/docs/components-authprovider--page). If authentication is valid, the children of the PrivateRoute are rendered. Otherwise, the user is redirected to the login page.
<Meta
title="Components/PrivateRoute"
component={PrivateRoute}
/>

<Meta title="Components/PrivateRoute" component={PrivateRoute} />
The PrivateRoute wraps [React Router](https://reactrouter.com/)'s [Route component](https://reactrouter.com/web/api/Route) and checks for authentication using [AuthProvider](/?path=/docs/components-authprovider--page). If authentication is valid, the children of the PrivateRoute are rendered. Otherwise, the user is redirected to `/login`.

export const Template = (props) => <PrivateRoute {...props} />
```js
<PrivateRoute path="/protected">
<Sensitive />
</PrivateRoute>
```

Props other than `children` and `path` can be passed to the underlying [Route component](https://reactrouter.com/web/api/Route).
```js
<PrivateRoute path="/" exact>
<Children />
</Private>
```

<ArgsTable of={PrivateRoute} />

All other props are passed to the [Route component](https://reactrouter.com/web/api/Route).

0 comments on commit eb6e5ff

Please sign in to comment.