Unblock React Compiler for 5 components by removing render-phase mutation (#11543)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
Tomasz Zawadzki
2026-08-31 23:03:13 +02:00
committed by GitHub
parent 0a00392b65
commit bfde8e60c2
6 changed files with 40 additions and 40 deletions
+7 -3
View File
@@ -11,14 +11,18 @@ import {
* Thin `useMemo` wrapper that marks the metadata as memoized and provides a * Thin `useMemo` wrapper that marks the metadata as memoized and provides a
* type guard. * type guard.
*/ */
export function useMeta(metadata?: MergeableMetadata) { function markMemoized<T extends MergeableMetadata>(m: T): T {
const m = useMemo(() => metadata, [metadata])
if (!m) return
// @ts-expect-error // @ts-expect-error
m.__meta = true m.__meta = true
return m return m
} }
export function useMeta(metadata?: MergeableMetadata) {
const m = useMemo(() => metadata, [metadata])
if (!m) return
return markMemoized(m)
}
export function accountToSessionMetadata( export function accountToSessionMetadata(
account: SessionAccount | undefined, account: SessionAccount | undefined,
): SessionMetadata | undefined { ): SessionMetadata | undefined {
+2 -2
View File
@@ -362,9 +362,9 @@ export function Composer({
onKeyPress={IS_WEB ? onKeyPressWeb : undefined} onKeyPress={IS_WEB ? onKeyPressWeb : undefined}
onScroll={e => { onScroll={e => {
if (IS_WEB) { if (IS_WEB) {
inputScrollSharedValue.value = (e.target as any).scrollTop inputScrollSharedValue.set((e.target as any).scrollTop)
} else { } else {
inputScrollSharedValue.value = e.nativeEvent.contentOffset.y inputScrollSharedValue.set(e.nativeEvent.contentOffset.y)
} }
}} }}
// @ts-expect-error web only // @ts-expect-error web only
+5 -4
View File
@@ -116,14 +116,15 @@ function Inner({
setActiveNux(undefined) setActiveNux(undefined)
}, [activeNux, setActiveNux]) }, [activeNux, setActiveNux])
if (__DEV__ && typeof window !== 'undefined') { useEffect(() => {
// @ts-expect-error if (!__DEV__ || typeof window === 'undefined') return
// @ts-expect-error debug only
window.clearNuxDialog = (id: Nux) => { window.clearNuxDialog = (id: Nux) => {
if (!__DEV__ || !id) return if (!id) return
resetNuxs([id]) resetNuxs([id])
unsnooze() unsnooze()
} }
} }, [resetNuxs])
useEffect(() => { useEffect(() => {
if (snoozed) return // comment this out to test if (snoozed) return // comment this out to test
+20 -27
View File
@@ -101,35 +101,28 @@ function ContentHiderActive({
} }
} }
const selfBlurCauses = []
let hasAdultContentLabel = false let hasAdultContentLabel = false
const selfBlurNames = modui.blurs for (const cause of modui.blurs) {
.filter(cause => { if (cause.type !== 'label') continue
if (cause.type !== 'label') { if (cause.source.type !== 'user') continue
return false if (ADULT_CONTENT_LABELS.includes(cause.label.val as AdultSelfLabel)) {
} if (hasAdultContentLabel) continue
if (cause.source.type !== 'user') { hasAdultContentLabel = true
return false }
} selfBlurCauses.push(cause)
if (ADULT_CONTENT_LABELS.includes(cause.label.val as AdultSelfLabel)) { }
if (hasAdultContentLabel) { const selfBlurNames = selfBlurCauses.slice(0, 2).map(cause => {
return false if (cause.type !== 'label') {
} return
hasAdultContentLabel = true }
}
return true
})
.slice(0, 2)
.map(cause => {
if (cause.type !== 'label') {
return
}
const def = cause.labelDef || getDefinition(labelDefs, cause.label) const def = cause.labelDef || getDefinition(labelDefs, cause.label)
if (def.identifier === 'porn' || def.identifier === 'sexual') { if (def.identifier === 'porn' || def.identifier === 'sexual') {
return l`Adult Content` return l`Adult Content`
} }
return getLabelStrings(i18n.locale, globalLabelStrings, def).name return getLabelStrings(i18n.locale, globalLabelStrings, def).name
}) })
if (selfBlurNames.length === 0) { if (selfBlurNames.length === 0) {
return desc.name return desc.name
+5 -3
View File
@@ -683,9 +683,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
const bundle = state.currentBundleState.bundle as unknown as const bundle = state.currentBundleState.bundle as unknown as
SessionBundle | PublicSessionBundle SessionBundle | PublicSessionBundle
// @ts-expect-error window type is not declared, debug only useEffect(() => {
// eslint-disable-next-line react-hooks/immutability if (!__DEV__ || !IS_WEB) return
if (__DEV__ && IS_WEB) window.bundle = bundle // @ts-expect-error window type is not declared, debug only
window.bundle = bundle
}, [bundle])
const currentBundleRef = useRef(bundle) const currentBundleRef = useRef(bundle)
/* /*
+1 -1
View File
@@ -332,7 +332,7 @@ export function TabBar({
syncScrollState.set('unsynced') syncScrollState.set('unsynced')
}} }}
onScroll={e => { onScroll={e => {
scrollX.value = Math.round(e.nativeEvent.contentOffset.x) scrollX.set(Math.round(e.nativeEvent.contentOffset.x))
}}> }}>
<Animated.View <Animated.View
onLayout={e => { onLayout={e => {