Skip to content
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

Merged
merged 6 commits into from
Oct 25, 2023

Conversation

snoh666
Copy link
Contributor

@snoh666 snoh666 commented Aug 21, 2023

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

let ObjectComponent = JsonObject;
if (typeof props.name === 'object' && !Array.isArray(props.name)) {
namespace = ['ReactElement'];
Copy link
Member

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 ? 🤔

Copy link
Contributor Author

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

@Kikobeats
Copy link
Member

@snoh666 thanks for this; I totally forgot 🙏

@Kikobeats Kikobeats merged commit dac4e76 into microlinkhq:master Oct 25, 2023
1 check passed
@Kikobeats
Copy link
Member

@snoh666 is "npm run build" working fine to you?

@snoh666
Copy link
Contributor Author

snoh666 commented Oct 26, 2023

@snoh666 is "npm run build" working fine to you?

Actually I can see some deps error related to create-react-app and babel

@Kikobeats
Copy link
Member

Yes :( I want to release your PR in the next version, but the building fails. I'm trying to determine what's happening.

@snoh666
Copy link
Contributor Author

snoh666 commented Oct 26, 2023

I'm pretty sure this should be a working fix #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants