mirror of
https://github.com/ZwareBear/awx.git
synced 2026-03-22 16:53:35 -05:00
24 lines
423 B
JavaScript
24 lines
423 B
JavaScript
import React from 'react';
|
|
import {
|
|
Route,
|
|
Redirect
|
|
} from 'react-router-dom';
|
|
|
|
const ConditionalRedirect = ({
|
|
component: Component,
|
|
shouldRedirect,
|
|
redirectPath,
|
|
location,
|
|
...props
|
|
}) => (shouldRedirect() ? (
|
|
<Redirect to={{
|
|
pathname: redirectPath,
|
|
state: { from: location }
|
|
}}
|
|
/>
|
|
) : (
|
|
<Route {...props} render={rest => (<Component {...rest} />)} />
|
|
));
|
|
|
|
export default ConditionalRedirect;
|