You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You cannot currently have an input that is optional and only sometimes rendered. This is because calling useValidatedInput requires its ref to be assigned to an input. If it's not, you get the following error:
Error in validateInput useEffect Error: validateInput expected an inputEl.form to be available for input "inputName"
at invariant2 (index.tsx:338:11)
at validateInput (index.tsx:419:5)
at go (index.tsx:975:26)
at index.tsx:1010:5
at commitHookEffectListMount (react-dom.development.js:23150:26)
at invokePassiveEffectMountInDEV (react-dom.development.js:25154:13)
at invokeEffectsInDev (react-dom.development.js:27351:11)
at commitDoubleInvokeEffectsInDEV (react-dom.development.js:27330:7)
at flushPassiveEffectsImpl (react-dom.development.js:27056:5)
at flushPassiveEffects (react-dom.development.js:26984:14)
You cannot conditionally call the hook itself of course, so it makes it impossible to have a situation like: if you are an admin, have an extra field in your "create item" form for the item's value. When a normal user creates an item, we do not want to render or validate that field because only admins can assign value. But when an admin creates an item, you want to validate that the item's value is in a range using this lovely library.
Hope that example makes sense.
The text was updated successfully, but these errors were encountered:
yeah this looks like it's missing a short circuit like the other useEffect calls. However, with the new type safety from #46 we may need to think about adding a new optional field to the definition. Otherwise the types will be wrong:
If the field is required when it's present, then the type of serverFormInfo.submittedValues.optionalField is going to be string which is wrong in the case it's not rendered.
Maybe we add the field alongside the multiple indicator:
You cannot currently have an input that is optional and only sometimes rendered. This is because calling
useValidatedInput
requires its ref to be assigned to an input. If it's not, you get the following error:You cannot conditionally call the hook itself of course, so it makes it impossible to have a situation like: if you are an admin, have an extra field in your "create item" form for the item's value. When a normal user creates an item, we do not want to render or validate that field because only admins can assign value. But when an admin creates an item, you want to validate that the item's value is in a range using this lovely library.
Hope that example makes sense.
The text was updated successfully, but these errors were encountered: