Comments (5)
Wow! Great catch - we'll tackle this ASAP
from form.
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.
Yes, it took some time to find the problem 😀
Thank you for your support!
from form.
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.
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)
- Values in nested arrays do not get updated properly
- [Tracking] Refactors prior to 1.x
- Array fields do not run onChange validation HOT 2
- Doubly nested array subfield infers `never` for value type HOT 8
- Mismatch in array handling between useForm and FormData HOT 3
- Error using useState & form.setFieldValue HOT 7
- Add a way to display only one error for a field HOT 3
- Calling `createFormFactory<FormData>` and using a validator adapter throw TS errors HOT 1
- onChangeAsyncDebounceMs not properly debouncing HOT 1
- TanStack/Angular - Error when resetting the form HOT 1
- Missing error when validating via form options instead of via field HOT 3
- Factory `onSubmit` function not invoked whenever factory.useForm gets provided with `onSubmit` itself HOT 2
- Unable to read properties in nested array table HOT 2
- Nested Values Disappear when using StrictMode HOT 5
- onMount Error is not revalidated when the user changes the input HOT 2
- server actions example errors when using zod adapter HOT 1
- Cannot infer types on arrays of union of objects HOT 1
- Moving subfields of array field mix their values HOT 1
- Bad performance with 100+ rows in an array field HOT 4
- insertFieldValue replaces item instead of adding a new one and shift existing items
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from form.