Skip to content

Commit

Permalink
Revert "fix: remove startTransition so mutation hook could update imm…
Browse files Browse the repository at this point in the history
…ediately (#2654)" (#2681)
  • Loading branch information
huozhi committed Jun 20, 2023
1 parent eb9444c commit 87c6e9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions _internal/src/utils/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MutableRefObject } from 'react'
import { useRef, useCallback, useState } from 'react'
import { useIsomorphicLayoutEffect } from './env'
import React, { useRef, useCallback, useState } from 'react'
import { useIsomorphicLayoutEffect, IS_REACT_LEGACY } from './env'

/**
* An implementation of state with dependency-tracking.
Expand Down Expand Up @@ -65,7 +65,11 @@ export const useStateWithDeps = <S = any>(
}

if (shouldRerender && !unmountedRef.current) {
rerender({})
if (IS_REACT_LEGACY) {
rerender({})
} else {
;(React as any).startTransition(() => rerender({}))
}
}
},
[rerender]
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/mutate-server-action.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test('mutate-server-action', async ({ page }) => {
test.skip('mutate-server-action', async ({ page }) => {
await page.goto('./mutate-server-action')
await page.getByRole('button', { name: 'mutate' }).click()
await expect(page.getByText('isMutating: true')).toBeVisible()
Expand Down

0 comments on commit 87c6e9d

Please sign in to comment.