Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(adapters/next): wrap setOptimisticSearchParams in startTransition #729

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

aryasaatvik
Copy link
Contributor

on next 15 app router. I was getting an error when updating a search param in a form input event handler. wrapping setOptimisticSearchParams with startTransition fixed it

<Input
  placeholder="https://example.com/font.woff2"
  {...field}
  onChange={(e) => {
    setWebFontUrl(e.target.value);
    field.onChange(e);
  }}
/>

error

ConsoleError: An optimistic state update occurred outside a transition or action. To fix, move the update to an action, or wrap with startTransition.
    at handleClientError (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/client/components/react-dev-overlay/internal/helpers/use-error-handler.js:41:17)
    at window.console.error (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/client/components/globals/intercept-console-error.js:39:56)
    at dispatchOptimisticSetState (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:7206:17)
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_fs2fclt7luqmp6njf5pcuqcefm/node_modules/nuqs/dist/chunk-2Q6GSII2.js:19:5)
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_fs2fclt7luqmp6njf5pcuqcefm/node_modules/nuqs/dist/index.js:407:13)
    at recursiveCompose (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_fs2fclt7luqmp6njf5pcuqcefm/node_modules/nuqs/dist/index.js:431:20)
    at compose (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_fs2fclt7luqmp6njf5pcuqcefm/node_modules/nuqs/dist/index.js:439:5)
    at flushUpdateQueue (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_fs2fclt7luqmp6njf5pcuqcefm/node_modules/nuqs/dist/index.js:406:9)
    at flushNow (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_fs2fclt7luqmp6njf5pcuqcefm/node_modules/nuqs/dist/index.js:353:42)
    at runOnNextTick (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]_fs2fclt7luqmp6njf5pcuqcefm/node_modules/nuqs/dist/index.js:368:21)
    "react": "19.0.0-rc-69d4b800-20241021",
    "next": "15.0.1",

Copy link

vercel bot commented Oct 31, 2024

@aryasaatvik is attempting to deploy a commit to the 47ng Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 6:52am

@franky47 franky47 added the deploy:preview Deploy a preview version of this PR on pkg.pr.new label Oct 31, 2024
Copy link

pkg-pr-new bot commented Oct 31, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/nuqs@729

commit: c9b523a

Copy link
Member

@franky47 franky47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@franky47 franky47 merged commit 01af1ea into 47ng:next Oct 31, 2024
27 checks passed
Copy link

🎉 This PR is included in version 2.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy:preview Deploy a preview version of this PR on pkg.pr.new released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants