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

useForm's initializing and useField's formInitializing do not agree with each other on load #9263

Open
tyteen4a03 opened this issue Nov 17, 2024 · 0 comments
Labels
created-by: Contributor status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@tyteen4a03
Copy link
Contributor

Describe the Bug

I don't know if this is a bug or intentional behavior, but useForm()'s initializing and useField's formInitializing do not agree with each other when the form is being loaded. This component highlights this behavior:

const TestClientField: UIFieldClientComponent = ()  => {
  const { initializing } = useForm();
  const { formInitializing } = useField({
    path: '',
  });

  if (initializing !== formInitializing) {
    console.log("initializing != formInitializing!", initializing, formInitializing);
  } else {
    console.log("initializing == formInitializing", initializing, formInitializing);
  }

  return <>test</>
}

Link to the code that reproduces this issue

https://github.com/tyteen4a03/payload-forminitializing-bug

Reproduction Steps

  1. Run the repro repo.
  2. Navigate to the Media collection
  3. Open the Console, then refresh the page.
  4. See the warning in the console: initializing != formInitializing! false true

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Node.js v22.11.0

Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.13.0
Relevant Packages:
  payload: 3.0.0-beta.133
  next: 15.0.0
  @payloadcms/db-mongodb: 3.0.0-beta.133
  @payloadcms/email-nodemailer: 3.0.0-beta.133
  @payloadcms/graphql: 3.0.0-beta.133
  @payloadcms/next/utilities: 3.0.0-beta.133
  @payloadcms/payload-cloud: 3.0.0-beta.133
  @payloadcms/richtext-lexical: 3.0.0-beta.133
  @payloadcms/translations: 3.0.0-beta.133
  @payloadcms/ui/shared: 3.0.0-beta.133
  react: 19.0.0-rc-65a56d0e-20241020
  react-dom: 19.0.0-rc-65a56d0e-20241020
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Contributor status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants