Commit c00032b
committed
Guard against missing context during SSR in TreeControls
`wrapRootElement` is only registered in `gatsby-browser.js`, not
`gatsby-ssr.js`, so during static HTML generation `useSkoHubContext()`
returns the raw `defaultState` object instead of `{ data, updateState }`.
That made `data` undefined at render time and broke SSR with
`Cannot read properties of undefined (reading 'sortBy')` for flat
schemes (where TreeControls now renders to host the sort selector).
Optional-chain the `data` reads in TreeControls so the component
renders harmlessly during SSR; the dropdown becomes interactive once
the browser hydrates inside the ContextProvider.
Verified with `npm run build` against the interactivityType fixture
(the exact page that was failing in CI).1 parent 45dcc9a commit c00032b
1 file changed
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
0 commit comments