mac-s-g / react-json-view

JSON viewer for react
https://mac-s-g.github.io/react-json-view/demo/dist/
MIT License
3.42k stars 530 forks source link

Add support for jsx element as name #452

Closed snoh666 closed 1 year ago

snoh666 commented 1 year ago

As part of requirement of my current project we needed to use customary designs root name of each tree so easiest solution would be to pass React Element

image

After trying some sketchy stuff I realized when I type cast JSX.Element as string nothing breaks within the library so started on checking out library code. After realization because of the support of false values in ObjectAttributes object type also works perfectly fine with exception that ObjectAttributes contains [Object object] as key

image

so it needed only adding handling to replace this {} to string to just be "ReactElement" string

image

Which I thought is the most appropriate name