Support custom input components
See original GitHub issueIt would be really great to support custom components, eg. custom inputs, datepickers, timepickers, etc.
As an option, a curried version of handleChange
can be created, smth like handleChangeFor
, so the usage could look as follows
Formik({
mapPropsToValues: props => ({
date: props.user.birthdate
})
})(({handleChangeFor}) => (
/// ...
<SomeDatePicker
onChange={handleChangeFor('date')}>
// ...
));
I know this can be done using setFieldValue
, but such utility function will help a lot.
Avoiding imperative onChange={value => setFieldValue('date', value)}
would be awesome.
Here’s a sample implementation 😉
handleChangeFor (field) {
return value => setFieldValue(field, value);
}
Would appreciate hearing your thoughts on this
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Custom input components - Sanity.io
This article will explore the pieces and steps necessary to create a custom input component from scratch.
Read more >Building Custom Input Components for Blazor using InputBase
In this post, I'm going to point out some limitations with Blazor's input components. I'll then show how you can build your own...
Read more >Custom input types - Vue Formulate
To do this, we need to write a custom component that handles the "autocomplete" input logic. Each type is designated as a component...
Read more >Input types for custom components - Builder.io
When you create custom components to use in Builder, there are two required inputs and a number of optional inputs to help you...
Read more >Vue custom input - DEV Community
Most of us have faced it: build a custom input component. There are multiple reasons behind it but in general, it has custom...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If anyone is curious, I ended up with hoc on top of Formik, smth like:
Considering all your “custom” inputs trigger
onChange
or similar, with{value}
as an argument.@eugene-kim I think the link has changed to https://github.com/jaredpalmer/formik#avoiding-new-functions-in-render - the heading in the README was changed, but the content of the paragraph is still the relevant bit you need.
/edit: relevant commit that changed the heading: https://github.com/jaredpalmer/formik/commit/ceb56399cf30c96fa9863a67df1e7dcaced746e4