This repository was archived by the owner on Feb 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/_pages/LandingPage/components/HeaderView/components/Astronaut Expand file tree Collapse file tree 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) => {
2424 } ) ;
2525 const dark = useAgile ( core . ui . ASTRONAUT_DARK ) ;
2626
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+
2739 useEffect ( ( ) => {
2840 if ( ! isRaised ) return ;
2941
@@ -50,7 +62,7 @@ const Astronaut: React.FC<Props> = (props) => {
5062 } ;
5163
5264 return (
53- < div className = { clsx ( styles . Container , className ) } >
65+ < div key = { String ( mounted ) } className = { clsx ( styles . Container , className ) } >
5466 < animated . div
5567 style = { animated_Astronaut }
5668 className = { styles . ImageContainer } >
You can’t perform that action at this time.
0 commit comments