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

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

Closed
kyaw-t opened this issue Feb 12, 2025 · 2 comments · Fixed by #170
Closed

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

kyaw-t opened this issue Feb 12, 2025 · 2 comments · Fixed by #170
Labels
bug Something isn't working

Comments

@kyaw-t
Copy link
Contributor

kyaw-t commented Feb 12, 2025

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
@CarlosNZ
Copy link
Owner

Excellent find, thanks. Appreciate the PR.

@CarlosNZ
Copy link
Owner

Closed by #170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants