Skip to content

Commit bc3edd9

Browse files
committed
Fix page prop fetching when getInitalProps method is undefined
1 parent fc801b6 commit bc3edd9

File tree

1 file changed

+39
-44
lines changed

1 file changed

+39
-44
lines changed

src/cloud/components/Router.tsx

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -174,55 +174,50 @@ const Router = () => {
174174
}
175175

176176
const abortController = new AbortController()
177-
if (pageSpec.getInitialProps != null) {
178-
Promise.all([
179-
initialized ? null : getGlobalData(),
180-
pageSpec.getInitialProps({
181-
pathname,
182-
search,
183-
signal: abortController.signal,
184-
}),
185-
])
186-
.then(([globalData, pageData]) => {
187-
if (globalData != null) {
188-
initGlobalData(globalData)
189-
}
190-
setPageInfo({
191-
Component: pageSpec.Component,
192-
pageProps: pageData,
177+
178+
Promise.all([
179+
initialized ? null : getGlobalData(),
180+
pageSpec.getInitialProps != null
181+
? pageSpec.getInitialProps({
182+
pathname,
183+
search,
184+
signal: abortController.signal,
193185
})
194-
nProgress.done()
186+
: {},
187+
])
188+
.then(([globalData, pageData]) => {
189+
if (globalData != null) {
190+
initGlobalData(globalData)
191+
}
192+
setPageInfo({
193+
Component: pageSpec.Component,
194+
pageProps: pageData,
195195
})
196-
.catch((error: Error) => {
197-
if (error.name === 'AbortError') {
198-
console.warn('Navigation aborted')
199-
console.warn(error)
200-
} else {
201-
console.error(error)
202-
if (!initialized) {
203-
initGlobalData({
204-
teams: [],
205-
invites: [],
206-
})
207-
}
208-
209-
setPageInfo({
210-
isError: true,
211-
Component: ErrorPage,
212-
pageProps: {
213-
error,
214-
},
196+
nProgress.done()
197+
})
198+
.catch((error: Error) => {
199+
if (error.name === 'AbortError') {
200+
console.warn('Navigation aborted')
201+
console.warn(error)
202+
} else {
203+
console.error(error)
204+
if (!initialized) {
205+
initGlobalData({
206+
teams: [],
207+
invites: [],
215208
})
216-
nProgress.done()
217209
}
218-
})
219-
} else {
220-
setPageInfo({
221-
Component: pageSpec.Component,
222-
pageProps: {},
210+
211+
setPageInfo({
212+
isError: true,
213+
Component: ErrorPage,
214+
pageProps: {
215+
error,
216+
},
217+
})
218+
nProgress.done()
219+
}
223220
})
224-
nProgress.done()
225-
}
226221

227222
intercom.update()
228223

0 commit comments

Comments
 (0)