AuthorizedRoute.jsx 538 Bytes
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5
import { Redirect, Route } from 'umi';
import React from 'react';
import Authorized from './Authorized';

const AuthorizedRoute = ({ component: Component, render, authority, redirectPath, ...rest }) => (
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
	<Authorized
		authority={authority}
		noMatch={
			<Route
				{...rest}
				render={() => (
					<Redirect
						to={{
							pathname: redirectPath,
						}}
					/>
				)}
			/>
		}>
		<Route {...rest} render={(props) => (Component ? <Component {...props} /> : render(props))} />
	</Authorized>
徐立's avatar
徐立 committed
22 23 24
);

export default AuthorizedRoute;