Skip to content

Commit

Permalink
fix(expo-router): showroom bug (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcalise authored Apr 19, 2024
1 parent 95e2ecf commit dfa1c8c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/recipes/ExpoRouter.md
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ const logo = require("assets/images/logo.png");
interface DemoListItem {
item: { name: string; useCases: string[] };
sectionIndex: number;
handleScroll?: (sectionIndex: number, itemIndex?: number) => void;
onPress?: () => void;
}

const slugify = (str: string) =>
Expand All @@ -1462,12 +1462,12 @@ const slugify = (str: string) =>
.replace(/[\s_-]+/g, "-")
.replace(/^-+|-+$/g, "");

const ShowroomListItem: FC<DemoListItem> = ({ item, sectionIndex }) => {
const ShowroomListItem: FC<DemoListItem> = ({ item, sectionIndex, onPress }) => {
const sectionSlug = item.name.toLowerCase();

return (
<View>
<Link href={{ pathname: "/showroom", params: { sectionSlug } }}>
<Link href={{ pathname: "/showroom", params: { sectionSlug } }} onPress={onPress}>
<Text preset="bold">{item.name}</Text>
</Link>
{item.useCases.map((u) => {
Expand All @@ -1476,6 +1476,7 @@ const ShowroomListItem: FC<DemoListItem> = ({ item, sectionIndex }) => {
<Link
key={`section${sectionIndex}-${u}`}
href={{ pathname: "/showroom", params: { sectionSlug, itemSlug } }}
onPress={onPress}
asChild
>
<ListItem text={u} rightIcon={isRTL ? "caretLeft" : "caretRight"} />
Expand Down Expand Up @@ -1529,7 +1530,6 @@ export default function DemoShowroomScreen() {
itemIndex,
sectionIndex,
});
toggleDrawer();
};

const scrollToIndexFailed = (info: {
Expand Down Expand Up @@ -1578,7 +1578,7 @@ export default function DemoShowroomScreen() {
}))}
keyExtractor={(item) => item.name}
renderItem={({ item, index: sectionIndex }) => (
<ShowroomListItem {...{ item, sectionIndex, handleScroll }} />
<ShowroomListItem {...{ item, sectionIndex, onPress }} />
)}
/>
</View>
Expand Down

0 comments on commit dfa1c8c

Please sign in to comment.