form icon indicating copy to clipboard operation
form copied to clipboard

Subscribe errors with NaN

Open pedro757 opened this issue 10 months ago • 0 comments

Describe the bug

The library actually works fine but Next.js shows an error in the bottom left corner and It's annoying, functionality is not affected AFAICT.

This only happens when I use NaN as defaultValue and then try to Subscribe to the value, it doesn't when using a empty string, it also works with zero as defaultValue.

What are the general recommendation about defaultValues ?

Image Image

Call Stack createUnhandledError ../../node_modules/next/src/client/components/errors/console-error.ts (18:35) handleClientError ../../node_modules/next/src/client/components/errors/use-error-handler.ts (31:33) console.error ../../node_modules/next/src/client/components/globals/intercept-console-error.ts (32:26) mountSyncExternalStore ../../node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js (5533:20) Object.useSyncExternalStore ../../node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js (23063:16) exports.useSyncExternalStore ../../node_modules/next/dist/compiled/react/cjs/react.development.js (1231:34) exports.useSyncExternalStoreWithSelector ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js (82:19) useStore ../../node_modules/@tanstack/react-store/src/index.ts (23:17) LocalSubscribe ../../node_modules/@tanstack/react-form/src/useForm.tsx (132:16) useForm.useState ../../node_modules/@tanstack/react-form/src/useForm.tsx (198:9) MyForm app/example/form.tsx (129:15) Page app/example/page.tsx (28:7)

Your minimal, reproducible example

https://github.com/pedro757/form-subscribe-error-NaN

Steps to reproduce

  1. bun dev
  2. See the error in the bottom left corner

Expected behavior

Not displaying the error

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Browser: Chromium
  • Browser Version: 134

TanStack Form adapter

react-form

TanStack Form version

v1.1.2 sandbox is latest

TypeScript version

v5.8.2

Additional context

No response

pedro757 avatar Mar 28 '25 14:03 pedro757