Skip to content

Commit a89f18e

Browse files
committed
Fix flashing wrong layout on init
1 parent f8ba726 commit a89f18e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changelog/2188.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix flashing wrong layout on init

src/app/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ import { IonicNativePlatformProvider } from './components/Ionic/components/Ionic
2727
export function App() {
2828
useRouteRedirects()
2929
const { i18n } = useTranslation()
30+
const [isResponsiveContextInitialized, setIsResponsiveContextInitialized] = React.useState(false)
3031
const isMobile = useContext(ResponsiveContext) === 'small'
3132

33+
React.useEffect(() => {
34+
// TODO: remove this if grommet fixes and runs this on useLayoutEffect
35+
// https://github.com/grommet/grommet/blob/9d3a8e4/src/js/components/Grommet/Grommet.js#L109-L111
36+
setIsResponsiveContextInitialized(true)
37+
}, [])
38+
39+
if (!isResponsiveContextInitialized) return null
3240
return (
3341
<FatalErrorHandler>
3442
<IonicNativePlatformProvider>

0 commit comments

Comments
 (0)