pixiebrix-extension
pixiebrix-extension copied to clipboard
Refactor Database storage field
Storage selection for Custom Form involves several actions and events that must go in a strict order and are not transparent for developers. The Database storage option is the most complex case. When Database is selected:
- The selection event updates the value of the field
- On the next render
AppServiceFieldgets the updated Formik state add a field with a service reference
When another option is selected (database is removed):
- The selection event updates the value of the field
- On the next render an effect checks for unused service references and cleans up the root
servicesfield.
Need to refactor:
-
AppServiceField. It can be included in theDatabaseFieldas a hook. -
usePruneUnusedServiceDependencieshook. It should be possible to work with the updated Formik state (an arbitrary object), so that updating the state and clearing the service references happen in the same render cycle.
Source code: FormRendererOptions
Related discussion: link