Refactoring

This commit is contained in:
2024-06-28 08:16:28 +02:00
parent 665da4be29
commit 51c9c1f4f3
5 changed files with 23 additions and 28 deletions
+15
View File
@@ -0,0 +1,15 @@
import { Dispatch, SetStateAction } from "react";
export type StateHook<T> = {
state: T;
setState: Dispatch<SetStateAction<T>>;
};
export type StateHookArray<T> = [
T,Dispatch<SetStateAction<T>>
]
export function parseStateHook<T>(hook:StateHookArray<T>):StateHook<T>{
const stateHook:Partial<StateHook<T>> = {};
[stateHook.state, stateHook.setState] = hook;
return stateHook as StateHook<T>
}