Skip to content

Commit

Permalink
fix hooks's StoreName default type
Browse files Browse the repository at this point in the history
  • Loading branch information
AkifumiSato committed Sep 12, 2023
1 parent ce4b2f7 commit e6b98a1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/location-state-core/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ const useStore = (storeName: DefaultStoreNames | string) => {
return store;
};

export const useLocationState = <T, StoreName extends string>(
export const useLocationState = <
T,
StoreName extends string = DefaultStoreNames,
>(
definition: LocationStateDefinition<T, StoreName>,
): [T, SetState<T>] => {
const storeState = useLocationStateValue(definition);
const setStoreState = useLocationSetState(definition);
return [storeState, setStoreState];
};

export const useLocationStateValue = <T, StoreName extends string>(
export const useLocationStateValue = <
T,
StoreName extends string = DefaultStoreNames,
>(
definition: LocationStateDefinition<T, StoreName>,
): T => {
const { name, defaultValue, storeName, refine } = useState(definition)[0];
Expand All @@ -60,7 +66,10 @@ export const useLocationStateValue = <T, StoreName extends string>(
return storeState;
};

export const useLocationSetState = <T, StoreName extends string>(
export const useLocationSetState = <
T,
StoreName extends string = DefaultStoreNames,
>(
definition: LocationStateDefinition<T, StoreName>,
): SetState<T> => {
const { name, defaultValue, storeName, refine } = useState(definition)[0];
Expand Down

0 comments on commit e6b98a1

Please sign in to comment.