-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for root name as jsx element #26
Conversation
src/js/components/JsonViewer.js
Outdated
let ObjectComponent = JsonObject; | ||
if (typeof props.name === 'object' && !Array.isArray(props.name)) { | ||
namespace = ['ReactElement']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if namespace = props.displayName
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! Added it.
Also handled If component is unnamed It will use Anonymous
exactly the same as most of the react debug tools
@snoh666 thanks for this; I totally forgot 🙏 |
@snoh666 is "npm run build" working fine to you? |
Actually I can see some deps error related to create-react-app and babel |
Yes :( I want to release your PR in the next version, but the building fails. I'm trying to determine what's happening. |
I'm pretty sure this should be a working fix #28 |
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
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 inObjectAttributes
object
type also works perfectly fine with exception that ObjectAttributes contains[Object object]
as keyso it needed only adding handling to replace this
{} to string
to just be"ReactElement" string
Which I thought is the most appropriate name