Odd setFieldTouched behavior
See original GitHub issueQuestion?
Hitting something odd with setFieldTouched
that I can’t quite figure out. I’m passing down setFieldTouched
from withFormik
to some inputs, and then doing:
handleBlur = () => {
const { name, setFieldTouched } = this.props;
setFieldTouched(name, true); // name = 'start'
};
Oddly, in some instances, this call is setting an object instead of just setting a bool:
Here is the error:
And here is the value of touched
:
If I change the call to this:
handleBlur = () => {
const { name, setFieldTouched } = this.props;
setFieldTouched(name); // Note, no second arg
};
Then my touched looks correct:
Just curious why the second argument of setFieldTouched
could be creating an object instead of just setting the value?
- Formik Version: 1.0.0-alpha.1
- React Version: 16.2.0
- OS: Ubuntu 16.04
- Node Version: 8.4
- Package Manager and Version: yarn 1.5.1
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:12 (2 by maintainers)
Top Results From Across the Web
material ui - Autocomplete multiple error - Stack Overflow
I am using material-ui in React.js. When using multiple in Autocomplete it gives me the error, Uncaught TypeError: (intermediate value)( ...
Read more >React Form using Formik, Material-UI and Yup.
setFieldTouched. There are a couple more props passed to your component, check the docs for all of them Formik Docs. Next go to...
Read more >Build Your Own Formik Using React Hooks with Jared Palmer
Formik makes forms in React easy by managing your form's state and providing validation on all of your fields. Under the hood, Formik...
Read more >formik - Bountysource
Currently using setFieldValue or setFieldTouched we can achieve a high level of control in those situations where the default behavior falls sort.
Read more >Disruptive Behaviors & ODD: Methods to Improve Conduct ...
Comprehensive Psychological, Behavioral & Educational Services in NYC for Children, Adolescents & Adults. — Availability for NY, NJ, CT, PA, ...
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 Free
Top 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
Were you able to have a look at the sandbox repo? The touched values are following what is set in the initial
mapPropsToValues
:ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we’ll re-open it.