This repository was archived by the owner on Feb 15, 2025. It is now read-only.
File tree 1 file changed +13
-1
lines changed
src/_pages/LandingPage/components/HeaderView/components/Astronaut
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,18 @@ const Astronaut: React.FC<Props> = (props) => {
24
24
} ) ;
25
25
const dark = useAgile ( core . ui . ASTRONAUT_DARK ) ;
26
26
27
+ const [ mounted , setMounted ] = useState ( false ) ;
28
+ // The astronaut theme on SSR is always the default theme but the site theme
29
+ // can be in a different mode. React hydration doesn't update DOM styles
30
+ // that come from SSR. Hence force a re-render after mounting to apply the
31
+ // current relevant styles. There will be a flash seen of the original
32
+ // styles seen using this current approach but that's probably ok. Fixing
33
+ // the flash will require changing the theming approach and is not worth it
34
+ // at this point.
35
+ useEffect ( ( ) => {
36
+ setMounted ( true ) ;
37
+ } , [ ] ) ;
38
+
27
39
useEffect ( ( ) => {
28
40
if ( ! isRaised ) return ;
29
41
@@ -50,7 +62,7 @@ const Astronaut: React.FC<Props> = (props) => {
50
62
} ;
51
63
52
64
return (
53
- < div className = { clsx ( styles . Container , className ) } >
65
+ < div key = { String ( mounted ) } className = { clsx ( styles . Container , className ) } >
54
66
< animated . div
55
67
style = { animated_Astronaut }
56
68
className = { styles . ImageContainer } >
You can’t perform that action at this time.
0 commit comments