meteor-interface
Version:
Simple Content Management System to generate your administration interface for Meteor and React.
26 lines (23 loc) • 584 B
JavaScript
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
import LoadingComponent from "../ui/components/LoadingComponent"
const ConditionnalRoute = ({
computedProps = {},
waitWhile = false,
condition = true,
Element = null,
redirect = "/",
...rest
}) => (
<Route
{...rest}
render={(props) => {
if (waitWhile) return <LoadingComponent />;
else if (condition) {
return <Element {...props} {...computedProps} />;
}
return <Redirect to={redirect} />;
}}
/>
);
export default ConditionnalRoute;