stuff, with a side of things

This commit is contained in:
Elijah Lucian
2021-07-15 13:51:57 -06:00
parent c62f88953e
commit 8e7fc05cd1
20 changed files with 21741 additions and 230 deletions
+2 -8
View File
@@ -1,21 +1,15 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { useAppContext } from '../../contexts/AppContext'
type Res<T> = {
data: T
}
export const useGet = <T>(path: string) => {
const appContext = useRef(useAppContext())
const [data, setData] = useState<T | null>(null)
const get = useCallback(async () => {
// if (appContext.current.mock) return setData(mockGet[path]?.() || null)
const data = await appContext.current.get<Res<T>>(path)
const data = await appContext.current.get<T>(path)
if (!data) return
setData(data.data)
setData(data)
}, [path])
useEffect(() => {