Refactoring
This commit is contained in:
@@ -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>
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
|
||||
export type StateHook<T> = {
|
||||
state: T;
|
||||
setState: Dispatch<SetStateAction<T>>;
|
||||
};
|
||||
export type StateHookArray<T> = [
|
||||
T,Dispatch<SetStateAction<T>>
|
||||
]
|
||||
Reference in New Issue
Block a user