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

Any plans on making a viewer-only?

Open aconrad opened this issue 1 year ago • 1 comments

Thanks for your work on this tool, it's a pretty JSON renderer.

I need a viewer, not an editor. I'm currently passing restrict* props to false, which works. But I was wondering whether a viewer-only component (e.g. import { JsonViewer } from "json-edit-react";) would help trim the size of my final bundle. Thoughts?

aconrad avatar Aug 16 '24 06:08 aconrad

Hey, thanks for your comments.

I hadn't really planned to do that. I'd be happy to export a different "Viewer" component, but that would just be a wrapper around the main component with preset props. So I don't think that would help with bundle size at all, since I wouldn't be making a separate codebase for it (and don't really have any desire to, to be honest).

CarlosNZ avatar Aug 16 '24 10:08 CarlosNZ

If you are looking for viewer-only, check this https://www.npmjs.com/package/react-json-tree

jpainam avatar Aug 23 '24 18:08 jpainam

If you are looking for viewer-only, check this https://www.npmjs.com/package/react-json-tree

I'll take a look, thanks. But is it as pretty as this one though? :)

aconrad avatar Aug 23 '24 22:08 aconrad

The lib react-json-tree is slightly larger according to bundlephobia.

https://bundlephobia.com/package/[email protected] https://bundlephobia.com/package/[email protected]

But I suppose the real test should be looking at the size of the lib after tree-shaking.

aconrad avatar Aug 23 '24 23:08 aconrad

How about just a single viewer prop, which would disable all editing capability, so syntax would be:

<JsonEditor data={myData} viewer />

It wouldn't really help with the bundle size though, as it wouldn't be a separate code base, it would just be a shorthand for manually adding all the disable editing props. Just wondering if people would find that useful, or if they're happy to just include the disable editing props?

CarlosNZ avatar Aug 23 '24 23:08 CarlosNZ

I think it's okay to leave it as is. I might fork the repo when I get a chance and experiment by ripping out the editing features and see how small we can get...

aconrad avatar Aug 24 '24 02:08 aconrad

I think it's okay to leave it as is. I might fork the repo when I get a chance and experiment by ripping out the editing features and see how small we can get...

It would be great if you could share it here too

jpainam avatar Aug 26 '24 04:08 jpainam