Releases: akuzko/re-use-form
Releases · akuzko/re-use-form
v3.5.1
Patch Description:
- Fixed
getError
helper returned byusePartial
hook. There was a flaw inuseCallback
's dependencies used for this function resulted in initial empty errors to forever stay in function's closure, forcing it it return undefined errors all the time. Thanks to @MrFreemind for reporting this bug.
v3.5.0
New Features
- Added ability to pass a function to
reset
form helper. When passed, it will be called with current form attributes, and it's return value will be assigned as next form attributes. This behaviour can be used to amend current "clean" form attributes in some way without affecting form'sisPristine
flag. - Added
setState
form helper. Designed for advanced usage, it takes an updater function and passes whole form's state to it. It's return value is assigned as next entire form state.
v3.4.0
New Features
- Added ability to pass function as an argument to form's
set
helper method. This function takes form attributes as it's only argument and should return an object with updates to be made. This behavior can be used to avoid dependency onattrs
(that is the most common thing to change) in component hooks, such asuseCallback
.
v3.3.0
v3.2.1
v3.2.0
Release Description
- Added support for controlled behavior for dedicated form hook
FormProvider
component:
function OrderEditor() {
const [attrs, setAttrs] = useState(initial);
const fillForm = useCallback(() => {
setAttrs({
username: 'Guest',
address: 'Home'
});
}, []);
return (
<>
<FormProvider attrs={attrs} onChange={setAttrs}>
<OrderForm />
</FormProvider>
<button onClick={fillForm}>Prefill form</button>
</>
);
}
v3.1.0
v3.0.0
Breaking Changes
- All form hooks now accept single
config
object with strict structure as their only argument. - Changed custom
onChange
handler API: custom handler now accepts input value as it's first argument, and the rest of properties, including input name, are passed as secondoptions
argument. useMoreValidations
hook has been dropped in favor of newuseConfig
hook.
New Features
useConfig
hook can be used to dynamically add additional configuration to the form.- Added
makeForm
helper to declare dedicated form hooks for building advanced and well-organized forms.