expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
33.91k stars 5.43k forks source link

useLocalSearchParams() is always returning {} when used inside of <Stack.Screen> #30625

Open petja opened 3 months ago

petja commented 3 months ago

Minimal reproducible example

https://github.com/petja/expo-use-local-search-params-issue-repro

Which package manager are you using? (Yarn is recommended)

pnpm

If the issue is web-related, please select the bundler (web.bundler in the app.json)

metro

Summary

useLocalSearchParams() is always returning {} when used inside of <Stack.Screen>'s options.headerRight. Instead of an empty object, it should return search params for the screen if given.

This worked before I upgraded from Expo 50 to 51, but not anymore.

Environment

expo-env-info 1.2.0 environment info: System: OS: macOS 14.5 Shell: 5.9 - /bin/zsh Binaries: Node: 20.12.1 - ~/.nvm/versions/node/v20.12.1/bin/node npm: 10.6.0 - ~/.nvm/versions/node/v20.12.1/bin/npm Managers: CocoaPods: 1.15.2 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 23.5, iOS 17.5, macOS 14.5, tvOS 17.5, visionOS 1.2, watchOS 10.5 IDEs: Android Studio: 2023.2 AI-232.10300.40.2321.11567975 Xcode: 15.4/15F31d - /usr/bin/xcodebuild npmPackages: expo: ~51.0.22 => 51.0.22 expo-router: ~3.5.18 => 3.5.18 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.74.3 => 0.74.3 react-native-web: ~0.19.10 => 0.19.12 npmGlobalPackages: eas-cli: 10.2.1 Expo Workflow: managed

pkfms commented 2 months ago

this worked on 3.5.17, I just updated to 3.5.20 and useLocalSearchParams() in headerTitle started returning an empty object

petja commented 2 months ago

I can confirm that downgrading to 3.5.17 helps. So the problem is for >=3.5.18.

petja commented 6 days ago

Can we somehow prioritize this issue? As I just tested, it's still present in expo-router 3.5.23. Every time I run expo install --fix to upgrade my other Expo packages, it also installs this broken version of expo-router, and I have to install an older version manually.