-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(2.0) Proposal: API changes #264
Comments
RenameCurrent: MotivationTo make the usage more intuitive and have better readability of the component. Usageimport { Only } from 'react-advanced-form'
<Only when={({ fields }) => fields.firstName.valid}>
{/* Conditional content */}
</Only> Advantages
Disadvantages
|
Renameexport default createField({
- enforceProps: () => ({
+ withProps: () => ({
propName: 'foo'
}),
}) MotivationTo be shorted and more intuitive.
|
Renameexport default createField({
- mapPropsToField: () => ({
+ getInitialState: () => ({
checked: true,
})
})
|
DeprecateDeprecate calling |
DeprecateI propose to remove MotivationReferencing
|
RenameI propose to rename the
MotivationI want for this getter function to be more evident of what it does. The name should reflect that it references a field's props and subscribes to its changes. |
Deprecate / Refine
- anyCallback = ({ fieldProps }) => {}
+ anyCallback = ({ fieldState }) => {} MotivationI feel at the moment these two terms are somehow interchangeable throughout the API. That is definitely not okay, as they need to be: a) whether merged, representing a field's record in the form's state |
FeatureIntroduce a flag to represent the entire form's validity state ( MotivationThis has been often requested, and is currently missing. It is worth a try of thinking this feature through. SpecificationWe can take a similar approach to Formik, introducing a form's prop which assumes the initial validity of the respective form. That is for the interface purpose alone, as that flag cannot technically control the actual validity. This may be the case, it just needs a clean API. Materials |
ChangeSimplify MotivationRight now the handler for manual field change update exposed from RAF for controlled fields has the same interface as the respective internal handler. While this is consistent from the API point of view, it makes to sense for the end-developer to provide such arguments as for example Specificationtype HandleFieldChange = (nextValue: any) => void Caveats
|
DeprecateNeed to consider the deprecation of submit callbacks:
MotivationSubmit callbacks are shorthands that can be handled using plain Promise chaining. It may be over-engineering at some point, thus it is worthy to consider removing them. |
(?) RefineSupport a function as a value for MotivationHaving export default createField({
initialValue: ({ props }) => {
const [day, month, year] = props.date.split('-')
return { day, month, year }
}
})(BirthDate) Having QuestionableUsing |
(?)
|
This is the summary ticket of the API changes to be introduced in the next major version
2.0
.Roadmap
The text was updated successfully, but these errors were encountered: