-
Notifications
You must be signed in to change notification settings - Fork 47k
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
react-test-renderer does not include key
on fragments
#11808
Comments
Want to send a PR with a fix? |
Sure, if you've got a pointer as to how it should look. Where would the key be? |
Maybe ReactTestRenderer.js. My gut feeling is there’s a switch there, and the Fragment case doesn’t specify keys. |
I meant in the output of EDIT: the I'm not sure if it makes sense to include it, except that it looks odd in Jest snapshots that it's gone. But maybe not? I don't write React at all (sadly), I just found it weird that |
Maybe it could be helpful to have them stay in tree for the test renderer result, but that would probably require some "fun" changes inside fiber 🤔 |
Do we include keys for the regular nodes? My intuition is it seems unnecessary. Keys are a hint to the reconciler about how the content changes over time. However snapshots are static. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
From the docs (https://reactjs.org/docs/fragments.html#keyed-fragments):
If I do this:
The result is:
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).
See above
What is the expected behavior?
That, somehow, the
key
is not lost. I'm not sure where it would make sense, but it should be in there somewhere.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.2.0
The text was updated successfully, but these errors were encountered: