redirect.tsx 445 B

12345678910111213141516171819
  1. import {useEffect} from 'react';
  2. import {InjectedRouter} from 'react-router';
  3. import {LocationDescriptor} from 'history';
  4. type Props = {
  5. router: InjectedRouter;
  6. to: LocationDescriptor;
  7. };
  8. // This is react-router v4 <Redirect to="path/" /> component to allow things
  9. // to be declarative.
  10. function Redirect({to, router}: Props) {
  11. // Redirect on mount.
  12. useEffect(() => router.replace(to), []);
  13. return null;
  14. }
  15. export default Redirect;