-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |