question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Odd setFieldTouched behavior

See original GitHub issue

Question?

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: image

And here is the value of touched:

image

If I change the call to this:

handleBlur = () => {
  const { name, setFieldTouched } = this.props;
  setFieldTouched(name); // Note, no second arg
};

Then my touched looks correct: image

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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
arist0tl3commented, Apr 9, 2018

Were you able to have a look at the sandbox repo? The touched values are following what is set in the initial mapPropsToValues:

image

0reactions
stale[bot]commented, Aug 22, 2018

ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we’ll re-open it.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found