Skip to content

Commit f81d245

Browse files
committed
Add note about Cumulative Layout Shift
1 parent 1e60c46 commit f81d245

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/server-side-rendering.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Server-Side Rendering
22

3-
The values returned from [`useBreakpoints()`](api.md#usebreakpoints) default to `undefined`, which is the case when:
3+
The `widthMatch` and `heightMatch` values returned from [`<Observe>`](api.md#observe) and [`useBreakpoints()`](api.md#usebreakpoints) default to `undefined`. This is the case when:
44

5-
* the observed min-size isn't specified in your [`options`](api.md#widths);
6-
* rendering a component server-side.
5+
- the observed min-size isn't specified in your [`options`](api.md#usebreakpoints);
6+
- rendering a component server-side.
77

8-
You can use this `undefined` value to display your component differently for SSR purposes. How you do it is up to you (loading component, default CSS styles, placeholder content, `null`, etc).
8+
You can use this `undefined` value to display your component differently for SSR purposes. How you do it is up to you (loading spinner component, default CSS styles, placeholder content, `null`, etc).
9+
10+
# ⚠️ Beware of [Cumulative Layout Shift](https://web.dev/cls/)
11+
12+
Remember, this is a JavaScript solution to a CSS problem. If you use React Breakpoints to apply different styles to your component based on their size, and you are rendering some HTML server-side, you may end up applying styles to your components that do not match their computed styles once JavaScript loads on the client. This means you could introduce a flash of incorrectly styled content (FOISC?).
13+
14+
Unfortunately, there is no easy way around it: this is the nature of the beast. If you care deeply about [CLS](https://web.dev/cls/) (and for public pages you probably should!), you need to keep this side-effect in mind.
15+
16+
However, React Breakpoints truly shines when you're building highly-responsive dashboards with graphs and tables, each individually responsive and aware of their own sizes. Dashboards for signed-in users generally don't suffer from SEO penalties like CLS, because they are not indexed by search engines.

0 commit comments

Comments
 (0)