What are the best practices and recommended usecases of <form.Subscribe>?
#1520
Replies: 2 comments
-
|
I use
If I understand correctly, this is the same as using using useStore, but useStore re-renders the whole component
|
Beta Was this translation helpful? Give feedback.
-
|
Another use I've given the subscribe is for errors on fields that don't have integrated error handling, for example if I have nested objects and I need to display the error at the object level in addition to the individual fields of that object or array (usually something like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am pretty confused of this feature, as the documentation is very compact and does not describe the possible different scenarios in-depth imo.
For example, I can see at least three different compiling scenarios for
<form.Subscribe>:I see that the latter two are probably just the same but different syntax?
But which usecases are suitable to return child form fields within a Subscribe?
I accidentaly wrapped the same form field inside a Subscribe (as can be seen in my code snippets above) to which the subscribe subscribes to because this is not easy to understand at first and I did not really understand what the Subscribe is really doing:
I am still not sure if this is the way how it should be done, I would rather intuitively expect another field to be the child for the selector of the first one?
But still, why would I need children here?
Suppose, my use case is to update the email field and derive its value from a sanitized userinput, i.e. lowercased and removed special characters. Normally I would use the
onChangeListenTobut it has this bug that I already reported #1410I would like to know the exact consequences of using the Subscribe with or without children and especially the special case where the child is equal to the selector, is this allowed?
Also in regards of reactivity: The docs say something about reactivity, but for completeness lets discuss it here again, is the Subscribe triggering any rerenders? If not, how would it be able to return different React Nodes conditionally in its children code then?
Beta Was this translation helpful? Give feedback.
All reactions