UNPKG

460 BTypeScriptView Raw
1import React from 'react';
2import { Route, Redirect } from 'react-router-dom';
3
4const RedirectWithStatus = ({ key, from, to, status }) => (
5 <Route render={({ staticContext }) => {
6 // there is no `staticContext` on the client, so
7 // we need to guard against that here
8 if (staticContext)
9 staticContext.status = status
10 return <Redirect key={key} from={from} to={to} />
11 }} />
12)
13export default RedirectWithStatus;
\No newline at end of file