Closed senghuotlay closed 1 year ago
@dalley8626 I think you missed the migration guide.
https://blog.expo.dev/introducing-expo-router-v2-3850fd5c3ca1
Update useSearchParams to useGlobalSearchParams or useLocalSearchParams depending on your needs.
Although i use const searchParams = useLocalSearchParams();
i still got this error
Property 'id' does not exist on type 'RouteParams<"/[...missing]"> | RouteParams<"/product/[id]"> | Record<string, string>'.
Property 'id' does not exist on type 'RouteParams<"/[...missing]">'.ts(2339)
all good, my type issue
Which package manager are you using? (Yarn is recommended)
yarn
Summary
I find it confusing as well, basically if i have sth like src/app/[...missing].tsx, and then src/app/product/[id].tsx in my
[id].tsx
import { Stack, useSearchParams } from "expo-router"; import { Text } from "react-native";
export const ProductScreen = () => { const searchParams = useSearchParams(); const id = searchParams?.id
return ( <>
); };
export default ProductScreen; i got this error
Property 'id' does not exist on type 'RouteParams<"/product/[id]"> | RouteParams<"/[...missing]"> | Record<string, string>'. Property 'id' does not exist on type 'RouteParams<"/[...missing]">'.ts(2339) and if i remove the [...missing].tsx, the typeerror goes away
Minimal reproducible example
none