react-json-editor-ajrm icon indicating copy to clipboard operation
react-json-editor-ajrm copied to clipboard

Question - How to get content not using onChange callback

Open kristijorgji opened this issue 3 years ago • 2 comments

I used this library in plain js as in typescript was not working for me.

Now I would like to read the content/state of the editor, but without using callback onChange I used onChange and is very slow, use case: I modify content in editor, then want to update a Save button enable/disable based on onChange if error is present in js code or not. This takes around 2 seconds to return so button is enabled and users can save wrong json.

So how can I make this on demand and use instead this scenario:

  1. User clicks button outside your editor, let say named "SAVE"
  2. Now from ref ?? or somehow would like to call your editor to get status, if json is valid, and if yes get the content, then store it somewhere

kristijorgji avatar Jul 02 '21 16:07 kristijorgji

You can get the current JSON object state from ref by using jsonInputRef.current.state.jsObject where jsonInputRef is the ref you get from your JsonInput component

adityamohta avatar Jul 21 '21 11:07 adityamohta

Would you mind showing the code snippet? I am very new in React and using this amazing json editor in my simple project.

Temtselt avatar Apr 24 '22 04:04 Temtselt

I no longer intend to update this project. I am working instead on a complete rewrite.

I'd like to thank you for using and taking interest in this project.

I also would like to apologize for not following up sooner. However, do realize for the most part this has been a one-man show, and the occasional contributions I used to receive. What I am saying is, I am in dire need of volunteers.

If this is something you would be interested in participating in, you can join in the discussion.

AndrewRedican avatar Jan 29 '23 03:01 AndrewRedican