stuff, with a side of things
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user