Files
shlink-web-client/src/servers/helpers/withoutSelectedServer.tsx
2024-08-07 12:35:57 +02:00

18 lines
492 B
TypeScript

import type { FC } from 'react';
import { useEffect } from 'react';
interface WithoutSelectedServerProps {
resetSelectedServer: () => unknown;
}
export function withoutSelectedServer<T extends object>(WrappedComponent: FC<WithoutSelectedServerProps & T>) {
return (props: WithoutSelectedServerProps & T) => {
const { resetSelectedServer } = props;
useEffect(() => {
resetSelectedServer();
}, [resetSelectedServer]);
return <WrappedComponent {...props} />;
};
}