vankop / jsoneditor-react

react wrapper implementation for https://github.com/josdejong/jsoneditor
MIT License
265 stars 106 forks source link

Reset this.err and call onError with error change #42

Closed TreavorPhilyaw closed 3 years ago

TreavorPhilyaw commented 4 years ago

This resolves two issues

When you change the value in the JSON editor only this.err is updated but is unreliable due to it not being cleared. So a call to onError would help https://github.com/vankop/jsoneditor-react/issues/17

Reset this.err when there is no longer an error with the json to make it more reliable https://github.com/vankop/jsoneditor-react/issues/30

kebby commented 4 years ago

+1 for this PR; I would really like to disable my save/apply buttons when the JSON in the code editor is invalid 👍

AndrewCeM commented 3 years ago

+1 for the PR. @vankop can you please take a look at this one?

vankop commented 3 years ago

thanks!

AndrewCeM commented 3 years ago

The latest master doesn't have changes from this PR. That's why 3.1.0 version doesn't expose error on the outside.

https://github.com/vankop/jsoneditor-react/commit/56b691b2ab20a48b7970e5f0a136db3205c31a58#diff-eae7657c27371bf5b9ac89baf7dcb1e5e5f42c869543843d4b15407ff756f24b

vejandla commented 3 years ago

@vankop Are we planning to release a new version any time soon? it has been a long time since this PR got merged. Appreciate help !!

vankop commented 3 years ago

@vejandla this PR partially released, problem here that code

if(this.props.onError) {
                  const error = typeof err === 'object' ? err.message : err;
                  this.props.onError(error);
                }

will trigger onError on every invalid JSON, but in mode=text it is ok to have invalid JSON