react-json-editor-ajrm
react-json-editor-ajrm copied to clipboard
Question - How to get content not using onChange callback
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:
- User clicks button outside your editor, let say named "SAVE"
- 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
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
Would you mind showing the code snippet? I am very new in React and using this amazing json editor in my simple project.
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.