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.

the Field parse prop function not called for initialValues

See original GitHub issue

I use the parse prop to turn boolean values from a checkbox into numbers (1 or 0)

<Field type="checkbox" parse={ v => v ? 1 : 0 } format={ v => !! v } name="some-name" component="input" /> some-label

It works when I check a box, but if the checkbox gets checked automatically thanks to initialValues and then I submit the form without touching that checkbox then its value is a boolean (the parse function was not called).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
luisherranzcommented, May 26, 2017

Here is an example: https://codesandbox.io/s/j2oyp3NWP

Developers can avoid this problem passing the parsed value to initialValues but I wonder if it makes more sense if this is managed by redux-form.

0reactions
lock[bot]commented, Apr 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating initialValues prop on Formik Form does not update ...
The initialValues prop in both Form.js and FormikWithRef.js also reflect that value.input = 3000; However, the input does not update, using ...
Read more >
Final Form Docs – `FieldProps`
The initial value for the field. This value will be used to calculate dirty and pristine by comparing it to the current value...
Read more >
Field - Redux Form
The function is given the fields current value, all other form values, the props passed to the form, and the name of field...
Read more >
Tutorial - Formik
Before we start. Welcome to the Formik tutorial. This will teach you everything you need to know to build simple and complex forms...
Read more >
React + Redux Form — Two ways to add initial values
We pass a prop called initialValues into the form instance component and the value is an object with the keys being the name...
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