Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nirmaoz/react-router6-redirect

Redirect component for react-router v6
https://github.com/nirmaoz/react-router6-redirect

react react-router react-router-dom-v6 react-router-v6 reactjs

Last synced: about 1 month ago
JSON representation

Redirect component for react-router v6

Awesome Lists containing this project

README

        

# react-router6-redirect
Redirect component for react-router v6.
Renders a `` component and handles any dynamic parts.

## Why is this needed?
react-router v6 `` component does not handle dynamic parts of the `to` prop.

## Install
```shell
npm i react-router6-redirect
```

## Setup
```js
import {Route} from 'react-router-dom'
import {Redirect} from 'react-router6-redirect';
```

## Usage
Important: each param name present in the `Redirect`'s `to` prop must exist in the `Route`'s `path` prop.
```jsx
}/>
```

## Supported props
```ts
export interface RedirectProps {
to: string;
state?: any;
relative?: RelativeRoutingType;
}
```