Unblock React Compiler for 18 components with value blocks inside try (#11548)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tomasz Zawadzki
2026-08-31 15:47:42 +02:00
committed by GitHub
parent 80d09a242d
commit 8bf5696d3c
18 changed files with 179 additions and 85 deletions
+4 -1
View File
@@ -261,7 +261,10 @@ export function useGetJoinLinkPreview() {
staleTime: STALE.SECONDS.FIFTEEN,
})
const found = data.joinLinkPreviews[0]
return isKnownJoinLinkPreview(found) ? found : undefined
if (isKnownJoinLinkPreview(found)) {
return found
}
return undefined
} catch (error) {
logger.error('Failed to fetch join link preview', {safeMessage: error})
return undefined
+17 -6
View File
@@ -13,6 +13,22 @@ type ServiceConfig = {
}[]
}
/**
* Module scope because React Compiler cannot lower a `??` inside a `try`, and
* `data` only exists once the request in that `try` resolves.
*/
function toServiceConfig(data: {
checkEmailConfirmed?: boolean
liveNow?: ServiceConfig['liveNow']
}): ServiceConfig {
return {
checkEmailConfirmed: Boolean(data.checkEmailConfirmed),
// @ts-expect-error not included in the lexicon atm
topicsEnabled: Boolean(data.topicsEnabled),
liveNow: data.liveNow ?? [],
}
}
export function useServiceConfigQuery() {
const client = useAppviewClient()
return useQuery<ServiceConfig>({
@@ -22,12 +38,7 @@ export function useServiceConfigQuery() {
queryFn: async () => {
try {
const data = await client.call(app.bsky.unspecced.getConfig)
return {
checkEmailConfirmed: Boolean(data.checkEmailConfirmed),
// @ts-expect-error not included in the lexicon atm
topicsEnabled: Boolean(data.topicsEnabled),
liveNow: data.liveNow ?? [],
}
return toServiceConfig(data)
} catch (e) {
return {
checkEmailConfirmed: false,