fix(dev): add param to route css so it is not deduped by react #14447
+192
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
React dedupes CSS files that are identical, which is a good default in the case of vanilla react where multiple components might require the same chunk of css however in react router where the route may mount the css chunk first before lazy loaded components have loaded can cause those lazy loaded components to loose their styles when the page is navigated away from.
To solve this, we add a small hash param to route level CSS in the dev package. I used a hash as opposed to a search param because it doesn't download the same CSS twice but the deduping is no longer happening. We still fetch the CSS on route changes, but this is the same behaviour we have now in react-router so i've assumed this is fine.
I've left the branch on my fork with the failing test displayed in 14415, but otherwise modified it here to be a test to keep long term.
Related issues