react-code-dataset / spectrum /src /helpers /signed-out-fallback.js
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
// @flow
import React from 'react';
import compose from 'recompose/compose';
import { withCurrentUser } from 'src/components/withCurrentUser';
import AuthViewHandler from 'src/views/authViewHandler';
const Switch = props => {
const { Component, FallbackComponent, ...rest } = props;
return (
<AuthViewHandler>
{authed => {
if (!authed) return <FallbackComponent {...rest} />;
return <Component {...rest} />;
}}
</AuthViewHandler>
);
};
// Connect that component to the Redux state
const ConnectedSwitch = compose(withCurrentUser)(Switch);
const signedOutFallback = (
Component: React$ComponentType<*>,
FallbackComponent: React$ComponentType<*>
) => {
return (props: *) => (
<ConnectedSwitch
{...props}
FallbackComponent={FallbackComponent}
Component={Component}
/>
);
};
export default signedOutFallback;