-
Notifications
You must be signed in to change notification settings - Fork 49.7k
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If a component rendered in a Fragment and then outside of it it is considered the same instance by React.
This means that:
<Fragment>
<Component />
</Fragment>shares state with:
<Component />I see how this could be seen as beneficial behavior and can be easily fixed with keys.
When I was conditionally rendering either one Material UI Button or two inside a fragment would cause the ripple effect from the first Button in the fragment to be "transferred" to the single Button which is odd since the JSX structure is different.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
https://github.com/dacioromero/react-unexpected-state-fragments
What is the expected behavior?
Fragments should be a factor that React considers when determining if instances of a component is the same. Components should be different instances between renders if one is placed inside a Fragment and another is not.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.11.0, Firefox Developer Edition 71.0b7, Ubuntu 19.10.
Not sure if this worked as I would expect in previous versions.