Skip to content

Commit

Permalink
fix: status booleans for useMutation
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Jun 17, 2020
1 parent a90274d commit 8f00a71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/queryCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,10 @@ export function queryReducer(state, action) {
const newState = switchActions(state, action)

Object.assign(newState, {
isLoading: newState.status === 'loading',
isSuccess: newState.status === 'success',
isError: newState.status === 'error',
isIdle: newState.status === 'idle',
isLoading: newState.status === statusLoading,
isSuccess: newState.status === statusSuccess,
isError: newState.status === statusError,
isIdle: newState.status === statusIdle,
})

return newState
Expand Down
12 changes: 11 additions & 1 deletion src/useMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,15 @@ export function useMutation(mutationFn, config = {}) {
}
}, [getConfig, state.error])

return [mutate, { ...state, reset }]
return [
mutate,
{
...state,
reset,
isIdle: state.status === statusIdle,
isLoading: state.status === statusLoading,
isSuccess: state.status === statusSuccess,
isError: state.status === statusError,
},
]
}

0 comments on commit 8f00a71

Please sign in to comment.