redwood
redwood copied to clipboard
Passing explicitly imported components to `Route.page` breaks css injection order
Given this setup:
- NotFoundPage .js
import "./NotFoundPage.scss";
export default () => null;
- Routes.js
<Route notfound page={ NotFoundPage } />
- index.js:
import "./index.scss"
...
ReactDOM.render(... <Routes /> ...)
Then the css injection order in which css file contents are being put as
- index.js > index.scss
- NotFoundPage.js > NotFoundPage.scss
If, however, we omit the Page autoimporting that happens behind the scenes and import the component which is being used as Route.page
by adding an import explicitly to Routes.js
:
import NotFoundPage from "./NotFoundPage";
Then css injection order changes into the following one:
- NotFoundPage.js > NotFoundPage.scss
- index.js > index.scss
... which can break page styles as it changes the specificity by changing the order in which rules are being applied onto the document.