Skip to content

Commit 45da651

Browse files
committed
Fix stylesheet precedence example
1 parent 9467bc5 commit 45da651

File tree

1 file changed

+8
-5
lines changed
  • src/content/reference/react-dom/components

1 file changed

+8
-5
lines changed

src/content/reference/react-dom/components/link.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ export default function SiteMapPage() {
158158

159159
### Controlling stylesheet precedence {/*controlling-stylesheet-precedence*/}
160160

161-
Stylesheets can conflict with each other, and when they do, the browser goes with the one that comes later in the document. React lets you control the order of stylesheets with the `precedence` prop. In this example, two components render stylesheets, and the one with the higher precedence goes later in the document even though the component that renders it comes earlier.
162-
163-
{/*FIXME: this doesn't appear to actually work -- I guess precedence isn't implemented yet?*/}
161+
Stylesheets can conflict with each other, and when they do, the browser goes with the one that comes later in the document. React lets you control the order of stylesheets with the `precedence` prop. In this example, three components render stylesheets, and the ones with the same precedence are grouped together in the `<head>`.
164162

165163
<SandpackWithHTMLOutput>
166164

@@ -172,17 +170,22 @@ export default function HomePage() {
172170
<ShowRenderedHTML>
173171
<FirstComponent />
174172
<SecondComponent />
173+
<ThirdComponent/>
175174
...
176175
</ShowRenderedHTML>
177176
);
178177
}
179178

180179
function FirstComponent() {
181-
return <link rel="stylesheet" href="first.css" precedence="high" />;
180+
return <link rel="stylesheet" href="first.css" precedence="first" />;
182181
}
183182

184183
function SecondComponent() {
185-
return <link rel="stylesheet" href="second.css" precedence="low" />;
184+
return <link rel="stylesheet" href="second.css" precedence="second" />;
185+
}
186+
187+
function ThirdComponent() {
188+
return <link rel="stylesheet" href="third.css" precedence="first" />;
186189
}
187190

188191
```

0 commit comments

Comments
 (0)