I am a beginner learning react native. I want to use the useSearchParams hook from 'expo-router', but I get the error message:
error: TypeError: 0, _expoRouter.useSearchParams is not a function (it is undefined)
So maybe the useSearchParams hook doesn't exist anymore (I am following this from a tutorial).
This is my code:
import { Stack, useRouter, useSearchParams } from 'expo-router'
const JobDetails = () => {
// get specific ID of job details page we are on
const params = useSearchParams();
const router = useRouter();
const { data, isLoading, error, refetch } = useFetch("job-details", {
job_id: params.id,
})
return (
<SafeAreaView style={{ flex: 1, backgroundColor: COLORS.lightWhite}}>
<Stack.Screen></Stack.Screen>
</SafeAreaView>
)
}
export default JobDetails
Am I correct in thinking that useSearchParams doesn't exist anymore? If so, I have come across useLocalSearchParams and useGlobalSearchParams. What are the use cases for both?
Which would therefore be better to use in my example above?