# React Hooks Types
# Setter
// The type of the second item returned by React.useState
type Setter<T> = Dispatch<SetStateAction<T>>;
# UseState
// The return type of React.useState
type UseState<T> = [T, Setter<T>];
# SoftStorage
type SoftStorage<T> = {
storage: Required<{ [K in keyof T]: StorageItem<T, K> }>;
storageHelper: StorageHelper;
itemStateDict: Record<keyof T, UseState<T[keyof T]>>;
properties: (keyof T)[];
};
Referenced Types
# SetterKey
type SetterKey<T> = PrefixedKey<T, 'set'>;
Referenced Types
# StorageState
type StorageState<T, K extends keyof T> = {
[Key in K]: T[K];
} & {
[Key in SetterKey<K>]: Setter<T[K]>;
} & {
[Key in ResetterKey<K>]: Resetter;
} & {
[Key in CheckerKey<K>]: Checker;
};
Referenced Types
# StateKey
type StateKey<T> = SuffixedKeys<T, 'state'>;
Referenced Types
# StorageStates
type StorageStates<T> = {
[SK in StateKey<T>]: RestoreSuffixedKey<SK, 'state'> extends keyof T
? StorageState<T, RestoreSuffixedKey<SK, 'state'>>
: never;
};