Git Product home page Git Product logo

Comments (5)

crutchcorn avatar crutchcorn commented on May 28, 2024 2

Wow! Great catch - we'll tackle this ASAP

from form.

crutchcorn avatar crutchcorn commented on May 28, 2024 2

This required a lot of investigation and internal discussion - thanks for your patience everyone!

Should now be fixed in TanStack Form 0.13.7 🎉

from form.

Hatzl avatar Hatzl commented on May 28, 2024

Yes, it took some time to find the problem 😀
Thank you for your support!

from form.

Hatzl avatar Hatzl commented on May 28, 2024

I think it has something to do with issue #495 . The crash point is also
state.meta.errors = Object.values(state.meta.errorMap).filter( (val) => val !== void 0 ); because errorMap is not defined.

from form.

fulopkovacs avatar fulopkovacs commented on May 28, 2024

Note

Edit: You don't have to read this long comment, I created a draft PR with a non-prod-ready solution to illustrate my point (I also explain my thoughts better there): #576

Original comment:

I don't know if I add anything valuable here, but to me, it looks like a new field instance (in form.getFieldInfo('firstName').instances) is created every time the firstName field is rendered, but deleted only every second time it's destroyed. I suspect that this is because the 1st runs are always triggered by <StrictMode> and there's a piece of logic in the useIsomorphicEffectOnce() hook, that prevents the cleanup function from being executed for "dummy React cycles" (this hook is used in useField()):

I think this is what leads to the number of Error messages growing every time we toggle the visibility of the firstName field in the CodeSandbox from the description:

instances.mp4

Locally I tried to remove the redundant field instances manually in the packages/form-core/src/FieldApi.ts file (lines 402-414), and it seemed to solve the issue, so I could be on the right track here:

    return () => {
      const preserveValue = this.options.preserveValue
      unsubscribe()
      if (!preserveValue) {
        delete info.instances[this.uid - 1] <-- this is the new line (NOT a real solution)
        delete info.instances[this.uid]
        this.form.deleteField(this.name)
      }


      if (!Object.keys(info.instances).length && !preserveValue) {
        delete this.form.fieldInfo[this.name]
      }
    }
instances-workaround.mp4

Honestly, I'm still very new to the internals of tanstack/form, so I'm just relying on my instincts here... @crutchcorn Does this make any sense? If yes, should I pick it up?

from form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.