Skip to content

Commit

Permalink
react really wants no side-effects during render
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed May 24, 2024
1 parent 7016b42 commit e728bfe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-query/src/__tests__/useMutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -718,15 +718,14 @@ describe('useMutation', () => {
.mockImplementation(() => undefined)
let boundary = false
function Page() {
const { mutate, error } = useMutation<string, Error>({
const { mutate, error } = useMutation<string>({
mutationFn: () => {
const err = new Error('mock error')
err.stack = ''
return Promise.reject(err)
},
throwOnError: () => {
boundary = !boundary
return !boundary
return boundary
},
})

Expand Down Expand Up @@ -758,6 +757,7 @@ describe('useMutation', () => {
})

// second error goes to boundary
boundary = true
fireEvent.click(getByText('mutate'))
await waitFor(() => {
expect(queryByText('error boundary')).not.toBeNull()
Expand Down

0 comments on commit e728bfe

Please sign in to comment.