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.

allow dot path & bracket path for setFieldValue, setFieldTouched, & setFieldError

See original GitHub issue

Bug

The exposed interface for setFieldValue, setFieldTouched, & setFieldError do not allow dot path names

Current Behavior

only first level field names can be set.

Desired Behavior

allow field names that contain dot path as well as bracket path.

Suggested Solutions

change the keyof Values type for the field argument to string

Info

  • Formik Version: 0.11.0-beta.1
  • OS: MacOS High Sierra 10.13.2
  • Node Version: 8.9.4
  • Package Manager and version: npm 5.6.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
timc13commented, Jan 29, 2018

please do the same for FormikTouched<Values>. same problem - we can’t access anything beyond top level values in touched

1reaction
weswighamcommented, Jan 29, 2018

I’d just add a second overload that takes a string argument for when you pass something that isn’t a direct key. There’s no way in the typesystem today to concatenate strings, so there’s no way to represent a full object path string as a type.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - How do I access current value of a formik field without ...
My props don't have any "values" field. EDIT: Found an ugly way: document.getElementsByName("countryCode")[0].value . A better way is ...
Read more >
formik - UNPKG
Sibling\n * objects along path retain the same internal js reference. ... order to keep array values consistent for both dot path and\n...
Read more >
Arrays and Nested Objects - Formik
The name props in Formik can use lodash-like dot paths to reference nested ... Using lodash-like bracket syntax for name string you can...
Read more >
formik @ 1.5.2 .. 1.5.4 - Package Diff
function setIn(obj, path, value) {. - var res = {}; ... setFieldValue=function(e,t,i){void 0===i&&(i=!0),r.didMount&&r. ... setFieldError,setFieldTouched:r.
Read more >
s28.bitdl.ir/Video/OREILLY_STRATA_DATA_AND_AI_SUPE...
If the value at `path`\n * has changed, return a shallow copy of obj with ... to keep array values consistent for both...
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