Skip to content

Commit

Permalink
[examples] fix post title flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
zetavg committed Oct 8, 2024
1 parent 211509b commit 64d4e2c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
21 changes: 12 additions & 9 deletions examples/one-recommended/app/(feed)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ export default function FeedLayout() {
<Slot />
) : (
<Stack
screenOptions={{
headerRight() {
return (
<View px="$2">
<ToggleThemeButton />
</View>
)
},
screenOptions={({ route }) => {
return {
title: (route?.params as any)?.preloadTitle || undefined,
headerRight() {
return (
<View px="$2">
<ToggleThemeButton />
</View>
)
},
}
}}
>
<Stack.Screen
Expand All @@ -30,7 +33,7 @@ export default function FeedLayout() {
},
}}
/>
<Stack.Screen name="post/[id]" options={{ title: 'Post' }} />
<Stack.Screen name="post/[id]" />
</Stack>
)}
</View>
Expand Down
11 changes: 10 additions & 1 deletion examples/one-recommended/code/feed/FeedCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ export const FeedCard = (props: FeedItem) => {
return props.disableLink ? (
content
) : (
<Link asChild href={`/post/${props.id}`}>
<Link
asChild
href={{
pathname: `/post/[id]`,
params: {
id: props.id.toString(),
...(typeof document === 'undefined' ? ({ preloadTitle: props.content } as any) : {}),
},
}}
>
{content}
</Link>
)
Expand Down

0 comments on commit 64d4e2c

Please sign in to comment.