diff options
author | Sebastian <sebasjm@gmail.com> | 2021-05-04 15:15:28 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-05-04 15:15:49 -0300 |
commit | 7fc5f0aa0b6e738521ee7339d1f0f0b20db9915d (patch) | |
tree | ebd5b26f1d0f4355d5b51ffd39ef61cbdbce1dbb /DESIGN.md | |
parent | 6d040035819e5c90a1bbe7940f4d204b2de5c1f4 (diff) | |
download | merchant-backoffice-7fc5f0aa0b6e738521ee7339d1f0f0b20db9915d.tar.gz merchant-backoffice-7fc5f0aa0b6e738521ee7339d1f0f0b20db9915d.tar.bz2 merchant-backoffice-7fc5f0aa0b6e738521ee7339d1f0f0b20db9915d.zip |
transfer list and notification
Diffstat (limited to 'DESIGN.md')
-rw-r--r-- | DESIGN.md | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -68,6 +68,36 @@ The core concepts are: * <Input /> an others: defines UI, create <input /> DOM controls and access the form with useField() +To use it you will need a state somewhere with the object holding all the form +information. + +``` +const [state, setState] = useState({ name: '', age: 11 }) +``` + +Optionally an error object an be built with the error messages + +``` +const errors = { + field1: undefined, + field2: 'should be greater than 18', +} +``` + +This 3 elements are use to setup the FormProvider + +``` +<FormProvider errors={errors} object={state} valueHandler={setState}> +...inputs +</FormProvider> +``` + +Inputs should handle UI rendering and use `useField(name)` to get: + + * error: the error message if there is one + * value: the current value of the object + * onChange: function to update the current field + # Custom Hooks |