Commit 36f480d
committed
🤖 fix: use useLayoutEffect for synchronous theme sync in Storybook
Root cause: Writing to localStorage in decorator was causing persistence
issues. Also, synchronous document writes bypassed ThemeProvider.
Fix:
- Use ThemeStorySync component with useLayoutEffect (not useEffect)
- useLayoutEffect runs synchronously before paint, preventing flashes
- Let ThemeProvider manage localStorage, don't write in decorator
- Chromatic modes will trigger ThemeStorySync with correct mode
This should fix the issue where both dark and light mode stories
were rendering in dark mode.1 parent d32f711 commit 36f480d
1 file changed
+19
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
7 | 22 | | |
8 | 23 | | |
9 | 24 | | |
| |||
23 | 38 | | |
24 | 39 | | |
25 | 40 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 41 | | |
37 | 42 | | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
| |||
0 commit comments