fix eslint errors

This commit is contained in:
John Mitchell
2018-10-24 21:51:35 -04:00
parent 2245d6a22e
commit 1caa5b1c54
3 changed files with 17 additions and 16 deletions

View File

@@ -4,19 +4,20 @@ import {
Redirect
} from 'react-router-dom';
const ConditionalRedirect = ({ component: Component, shouldRedirect, redirectPath, ...props }) => {
if (shouldRedirect()) {
return (
<Redirect to={{
pathname: redirectPath,
state: { from: props.location }
}}/>
);
} else {
return (
<Route {...props} render={props => (<Component {...props}/>)} />
);
}
};
const ConditionalRedirect = ({
component: Component,
shouldRedirect,
redirectPath,
location,
...props
}) => (shouldRedirect() ? (
<Redirect to={{
pathname: redirectPath,
state: { from: location }
}}
/>
) : (
<Route {...props} render={rest => (<Component {...rest} />)} />
));
export default ConditionalRedirect;
export default ConditionalRedirect;