pgForm/Concepts/Dynamic props
Concept
Dynamic props
Required, disabled, hidden, options, validators — any prop can be a function of the form.
Content coming soon. Outline:
- The
DynamicPropshape —handler,fieldDependencies,formDependencies - The shorter
field.use()/form.use()form - Why you must hoist all
.use()calls to the top of the function
TShoisting.ts
// BAD // GOOD (field) => { (field) => { if (field.use('hasErrors')) const hasErrors = field.use('hasErrors') return field.use('firstError') const firstError = field.use('firstError') return field.use('label') const label = field.use('label') } return hasErrors ? firstError : label }