-
Notifications
You must be signed in to change notification settings - Fork 26
key prop is ignored #19
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
Comments
Can you please provide an example on how you are trying to call |
The problem is that if you do something like this: let c = <Component>
<Item key={1}/>
<Item key={2}/>
</Component>;
console.log(jsxToString(c)); the output will be: <Component>
<Item/>
<Item/>
</Component> but should be: <Component>
<Item key={1}/>
<Item key={2}/>
</Component> |
Weird. thanks for sharing. let me try that locally. |
I cannot seem to reproduce it. And even in your site I can see the props are there:
|
Yep, props are there but the key prop isn't. Use the chrome inspector + React plugin and you will see that every BoxChild has a key prop but it's not displayed. So the problem is not with all the props, but the key prop. I will try to find out what's the problem, because if you couldn't reproduce it, maybe is related with dependencies versions. |
I see the problem you are facing now.
I cannot think about a good way of solving this with jsx-to-string. If you have any ideas on how to solve this please advise. |
To read the key from an element, just read it: |
It's not a clean solution but it's useful. |
Access is not “disabled” to Otherwise React itself wouldn’t be able to read it. 😉 |
EDIT: |
Could you explain the problem to me? Key is not on props intentionally. This is explained in facebook/react#2429: you don't want to accidentally copy it over to another element, for example. It doesn't behave like a prop, and shouldn't be one. But a library like |
Thanks @gaearon I will make the modification on |
Fixed in a48363c. Released 1.0.1 with support for this. |
Hi, thanks for this work, I'm currently using it on a code Highlight component and works pretty well.
But one of the problems I could find is that the key prop is removed. I need that to show my code examples so the user can just copy/paste the code without getting any warnings.
Is there any way to enable this?
You can see the problem here: https://erasmo-marin.github.io/suitup-toolkit-website/
The text was updated successfully, but these errors were encountered: