mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-17 13:03:50 +00:00
Create useSelectedServer hook and use it where reset selected server is done
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user