YYsuni / react18-json-view

JSON viewer for react18
https://jv.yysuni.com/
MIT License
236 stars 15 forks source link

Allow onEdit to prevent a value from being updated #42

Open felldiddy opened 2 months ago

felldiddy commented 2 months ago

It would be very useful to use the onEdit handler to prevent a value from being updated, for instance:

<JsonView src={data} editable={{ edit: true }} onEdit={({ newValue }) => newValue === "something bad" ? false : true} />

In particular, this would support behavior where I don't want to allow a field that's a number to be changed to a string, or vice-versa (for one use case) by comparing the type of the old value to the type of the new value.