react-json-view icon indicating copy to clipboard operation
react-json-view copied to clipboard

Is there a way to expand to a certain state?

Open olly-writes-code opened this issue 8 months ago • 2 comments

Hi! What I'm trying to do is keep the json expanded state so that when I close the component and re-open it the expansion isn't lost. I don't see any obvious way to pass an expansion map. Any thoughts on how to do this? Thank you!!

olly-writes-code avatar Jun 13 '25 05:06 olly-writes-code

https://github.com/uiwjs/react-json-view/blob/b1c5b0d53dfd1bc1107e5ec67387fcf9ad23b586/core/README.md?plain=1#L736-L741

https://github.com/uiwjs/react-json-view/blob/b1c5b0d53dfd1bc1107e5ec67387fcf9ad23b586/core/README.md?plain=1#L733-L736

https://github.com/uiwjs/react-json-view/blob/b1c5b0d53dfd1bc1107e5ec67387fcf9ad23b586/core/src/index.tsx#L60-L64

@olly-writes-code

jaywcjlove avatar Jun 13 '25 06:06 jaywcjlove

I think that is half of what is needed, a way of setting what is expanded. The other half would be a way of knowing what is already expanded, so you can save it (or in my case make a small alteration).

From https://github.com/uiwjs/react-json-view/issues/59, I think that the onExpand event could be used to update an object with what is currently expanded/collapsed, so it can be used later.

doctau avatar Oct 09 '25 11:10 doctau