CarlosNZ/json-edit-react

Bug report: Component crashes when onUpdate prevents changing data type to Object

Closed this issue · 2 comments

Describe the bug

The component crashes when the user tries to update a string/number/boolean to an object but the onUpdate function returns an error.

This seems to be happening because the ValueComponent tries to render it as a string/number/boolean even though the value it is trying to render is an object.

The screenshot shows that the dataType (string) is correct but the value it is trying to render is the value that was rejected by onUpdate.

Expected behavior

The component should not crash and should instead render the correct value

Screenshots

Image

Online demo

Steps to reproduce in code sandbox:
https://codesandbox.io/p/sandbox/json-edit-react-demo-forked-gc9z6x?file=%2Fsrc%2FApp.js%3A6%2C65

  • change type of hello to an object

Steps to reproduce in online demo:

  • select JSON Schema Validation for the demo data
  • change type of data.name from string to an object

Excellent find, thanks. Appreciate the PR.

Closed by #170