Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
feat: add function type
Browse files Browse the repository at this point in the history
  • Loading branch information
Bayathy committed Dec 11, 2022
1 parent fb41ade commit a337185
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/hooks/use-store-list.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { getList, StoreList } from "libs/firebase/store";
import { useState, useMemo } from "react";

export const useStoreList = (uuid: string) => {
const [storeList, setListState] = useState<StoreList>([]);
const [isLoading, setLodingState] = useState<boolean>(true);
useMemo(() => {
getList(uuid).then((res) => {
setListState(res);
setLodingState(false);
});
}, [uuid]);

return [storeList, setListState, isLoading];
};
import { getList, StoreList } from "libs/firebase/store";
import { useState, useMemo } from "react";
import type { Dispatch, SetStateAction } from "react";

export const useStoreList = (
uuid: string,
): [StoreList, Dispatch<SetStateAction<StoreList>>, boolean] => {
const [storeList, setListState] = useState<StoreList>([]);
const [isLoading, setLodingState] = useState<boolean>(true);
useMemo(() => {
getList(uuid).then((res) => {
setListState(res);
setLodingState(false);
});
}, [uuid]);

return [storeList, setListState, isLoading];
};

0 comments on commit a337185

Please sign in to comment.