1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/ui/helpers/higher-order-components/feature-toggled-route.js

16 lines
425 B
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import { Redirect, Route } from 'react-router-dom';
2020-10-06 20:28:38 +02:00
2020-11-03 00:41:28 +01:00
export default function FeatureToggledRoute({ flag, redirectRoute, ...props }) {
2020-10-06 20:28:38 +02:00
if (flag) {
return <Route {...props} />;
2020-10-06 20:28:38 +02:00
}
return <Redirect to={{ pathname: redirectRoute }} />;
2020-10-06 20:28:38 +02:00
}
FeatureToggledRoute.propTypes = {
flag: PropTypes.bool.isRequired,
redirectRoute: PropTypes.string.isRequired,
};