Create useSelectedServer hook and use it where reset selected server is done

This commit is contained in:
Alejandro Celaya
2025-11-14 09:54:03 +01:00
parent b295240d28
commit 7890d0084a
6 changed files with 41 additions and 17 deletions

View File

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