@skyscanner/backpack-web 41.6.0 → 41.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,14 @@
19
19
  import { useEffect, useState } from 'react';
20
20
  const useMediaQuery = (query, matchSSR = false) => {
21
21
  const isClient = typeof window !== 'undefined' && !!window.matchMedia;
22
- const [matches, setMatches] = useState(isClient ? window.matchMedia(query).matches : matchSSR);
22
+ const [matches, setMatches] = useState(() => {
23
+ // When matchSSR=true: use matchSSR value to match server-rendered HTML
24
+ // This prevents hydration errors when User-Agent (server) != viewport size (client)
25
+ if (!isClient || matchSSR) {
26
+ return matchSSR;
27
+ }
28
+ return window.matchMedia(query).matches;
29
+ });
23
30
  useEffect(() => {
24
31
  if (isClient) {
25
32
  const media = window.matchMedia(query);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "41.6.0",
3
+ "version": "41.7.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",