Created component decorator that resets selected server and used it on Settings

This commit is contained in:
Alejandro Celaya
2020-09-06 13:10:30 +02:00
parent 98d856700c
commit 1b1a1f3230
6 changed files with 26 additions and 14 deletions

View File

@@ -0,0 +1,15 @@
import React, { FC, useEffect } from 'react';
interface WithoutSelectedServerProps {
resetSelectedServer: Function;
}
export function withoutSelectedServer<T = {}>(WrappedComponent: FC<WithoutSelectedServerProps & T>) {
return (props: WithoutSelectedServerProps & T) => {
useEffect(() => {
props.resetSelectedServer();
}, []);
return <WrappedComponent {...props} />;
};
}