Skip to content

Commit

Permalink
Keep TS happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Mar 28, 2021
1 parent 8ebeb98 commit 30e9171
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react-async/src/useAsync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "./reducer"

import {
AsyncAction,
AsyncOptions,
AsyncState,
AbstractState,
Expand Down Expand Up @@ -60,7 +61,9 @@ function useAsync<T>(arg1: AsyncOptions<T> | PromiseFn<T>, arg2?: AsyncOptions<T
const { devToolsDispatcher } = globalScope.__REACT_ASYNC__
const { reducer, dispatcher = devToolsDispatcher } = options
const [state, _dispatch] = useReducer(
reducer ? (state, action) => reducer(state, action, asyncReducer) : asyncReducer,
reducer
? (state: AsyncState<T>, action: AsyncAction<T>) => reducer(state, action, asyncReducer)
: asyncReducer,
options,
init
)
Expand Down Expand Up @@ -336,5 +339,7 @@ const unsupported = () => {
)
}

// @ts-ignore
export default useEffect ? useAsync : unsupported
// @ts-ignore
export const useFetch = useEffect ? useAsyncFetch : unsupported

0 comments on commit 30e9171

Please sign in to comment.