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

there is something wrong with insertFieldValue #392

Closed
MadSummer opened this issue Sep 23, 2022 · 1 comment
Closed

there is something wrong with insertFieldValue #392

MadSummer opened this issue Sep 23, 2022 · 1 comment

Comments

@MadSummer
Copy link

the insertFieldValue is wrong ?

  const insertFieldValue = React.useCallback((field, index, value, options) => {
    apiRef.current.setFieldValue(
      field,
      old => {
        if (Array.isArray(old)) {
          return old.map((d, i) => (i === index ? value : d))
        } else {
          throw Error(
            `Cannot insert a field value into a non-array field. Check that this field's existing value is an array: ${field}.`
          )
        }
      },
      options
    )
  }, [])
@crutchcorn
Copy link
Member

This issue should be resolved now as of:

#404

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