CarlosNZ / json-edit-react

React component for editing/viewing JSON/object data
https://carlosnz.github.io/json-edit-react/
MIT License
187 stars 18 forks source link

Expose a callback "onError" to handle error by ourselves #71

Closed nicolasmuller closed 5 months ago

CarlosNZ commented 5 months ago

Yes, I've thought about this, seems like a good idea. I'll add it to the to-do list.

I may post back here with more discussion points once I take a closer look at it.

CarlosNZ commented 5 months ago

@nicolasmuller, would you prefer that when you pass in an onError function, that the component's own error messages don't display at all?

I might have to make that an additional option, as I can both ways being useful -- you might want to perform a side effect (e.g. cancel a database transaction), but you might also want to display your own error UI elsewhere (in which case you wouldn't want the component's error message).

CarlosNZ commented 5 months ago

Hi @nicolasmuller,

I've implemented a version of this and released it as v1.12.0-rc1. Let me know if it works for you.

Documentation here: https://www.npmjs.com/package/json-edit-react#onerror-function