Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to update the new value to state ? #6

Open
liu-wh opened this issue Jul 17, 2023 · 4 comments
Open

how to update the new value to state ? #6

liu-wh opened this issue Jul 17, 2023 · 4 comments

Comments

@liu-wh
Copy link

liu-wh commented Jul 17, 2023

onEdit method seems to only provider newValue, oldValue, if don't have key, how can I update the state?
I want to use this component as a form component, so that users can edit json, submit the form, I need to use state to collect the json input by the user

jaywcjlove added a commit that referenced this issue Jul 17, 2023
github-actions bot pushed a commit that referenced this issue Jul 17, 2023
@jaywcjlove
Copy link
Member

jaywcjlove commented Jul 17, 2023

@liu-wh Provides a namespace to return to where you changed the object

const data = {
  string: 'Lorem ipsum dolor sit amet',
  integer: 42,
  float: 114.514,
  object: {
    'first-child': true,
    'second-child': false,
    'last-child': null,
    'child': {
      'first': true,
      'second': false,
      'last': null,
    },
  },
  nestedArray: [ [1, 2], [3, 4], { a: 1} ],
}
onEdit={(opts) => {
  console.log('opts:', opts)
  // opts.namespace: ['object', 'child', 'last']
  //                 ['nestedArray', 0, 1]
  // opts.oldValue: null
  // opts.type: "value"
  // opts.value: "NULL3"
  return true;
}}

E.g: namespace = ['object', 'child', 'last']

data.object.child.last

E.g: namespace = ['nestedArray', 0, 1]

data.nestedArray[0][1]

@liu-wh
Copy link
Author

liu-wh commented Jul 31, 2023

@jaywcjlove thanks for your update !
And when I try to use onDelete props, Does it seem like it won't call the CountInfoExtraProps ? I can't use onDelete to update state.

jaywcjlove added a commit that referenced this issue Aug 1, 2023
jaywcjlove added a commit that referenced this issue Aug 1, 2023
@jaywcjlove
Copy link
Member

@liu-wh Upgrade v1.8.3

github-actions bot pushed a commit that referenced this issue Aug 1, 2023
@liu-wh
Copy link
Author

liu-wh commented Aug 8, 2023

@jaywcjlove v1.8.3 is ok, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants