Skip to content

Commit 74a6feb

Browse files
committed
fix missing type
1 parent a8e7e26 commit 74a6feb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-api-fetching",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Make fetching API easier with React's hooks + context",
55
"source": "src/index.tsx",
66
"main": "dist/main.js",

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef } from 'react'
22
import { deepEqual, deepMerge, generateCacheKey, generateConcurrentFn, isCached } from './utils'
33
import { useValueRef, useEnhancedMemo, useCachedData } from './hooks'
4-
import { Cache } from './cache'
4+
import { ApiResult, Cache } from './cache'
55
export { Cache } from './cache'
66

77
export type ApiVariables<T extends Partial<Record<'body' | 'query' | 'body', any>> = {}> = T
@@ -76,7 +76,7 @@ function createUseLazyApi<
7676
const [variables, setVariables] = useReducer(reducer as typeof reducer<TApiVariables>, (defaultOpts.variables || {}) as TApiVariables)
7777
const variablesRef = useValueRef(variables)
7878
const cacheKey = useMemo(() => generateCacheKey(key, variables), [key, variables])
79-
const result = useCachedData(cacheKey, cache)
79+
const result = useCachedData(cacheKey, cache) as ApiResult<TApiData, TApiError>
8080
const prevResultRef = useRef({})
8181

8282
const fetch = useCallback(async (opts: Pick<UseLazyApiOptions<TApiData, TApiError, TApiVariables>, 'variables'> = {}) => {

0 commit comments

Comments
 (0)