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.

Data from top level fields with same name as nested fields is cloned

See original GitHub issue

Bug, Feature, or Question?

Bug

Current Behavior

When a nested field object with same name as a root one changes, all the properties from top level field are copied to the nested field.

Example:

<Form>
  <Field name="user[name]">
  <Field name="user[lastName]">
  <Field name="nested[user][moreData]">
</Form>

Result

{
  user: {
    name: 'John',
    lastName: 'Doe'
  },
  nested: {
    user: {
      name: 'John', // is copied from root on moreData change
      lastName: 'Doe', // is copied from root field on moreData change
      moreData: 123
    }
  }
}

Desired Behavior

Data from top level fields with same name as nested fields should not be copied.

Suggested Solutions

Additional Information

I also tried with dot notation with same results.


  • Formik Version: “^0.11.11”
  • React Version: “^16.2.0”
  • TypeScript Version:
  • CodeSandbox Link: https://codesandbox.io/s/3vrk45xjzp
  • OS: macOS Sierra 10.12.6
  • Node Version: v8.4.0
  • Package Manager and Version: yarn v1.3.2

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
landonaldercommented, Jun 26, 2018

I am having this same issue with nested <FieldArray>s

0reactions
AxelRamirocommented, Sep 11, 2018

It works! Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Specify nested and repeated columns in table schemas
To create a column with nested data, set the data type of the column to RECORD in the schema. A RECORD can be...
Read more >
3 Ways to Clone Objects in JavaScript | SamanthaMing.com
Because objects in JavaScript are references values, you can't simply just copy using the = . But no worries, here are 3 ways...
Read more >
Nested field type | Elasticsearch Guide [8.5] | Elastic
The nested type is a specialised version of the object data type that allows arrays of objects to be indexed in a way...
Read more >
Find a value in multiple nested fields with the same name in ...
I'm trying to make a query that can find all documents with a given value in the field name across the different second...
Read more >
Methods for deep cloning objects in JavaScript - LogRocket Blog
A question that arises here is copying deeply nested objects up to, say, two or three levels deep in such a way that...
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