Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed types for Stack.Screen options is incorrect #28251

Open
ljukas opened this issue Apr 17, 2024 · 0 comments
Open

Exposed types for Stack.Screen options is incorrect #28251

ljukas opened this issue Apr 17, 2024 · 0 comments
Assignees
Labels
needs review Issue is ready to be reviewed by a maintainer Router expo-router

Comments

@ljukas
Copy link

ljukas commented Apr 17, 2024

Minimal reproducible example

https://github.com/ljukas/expo-router-bugs

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

yarn

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

None

Summary

Stack.Screen options are according to expo-router types required to extend Record<string, any>. Whilst this is correct it also accepts a function which supplies the route and the closest navigation as params. Which makes certain things possible, such as this:

<Stack.Screen
        name="test"
        options={({ navigation }) => ({
          headerBackVisible: navigation.getState().index > 0,
        })}
 />

Which is very useful in nested navigators. Since the "canGoBack" prop might still be true but you might not want to show the back button.

Right now using this approach still works fine, its just the types that are incorrect. It would be nice if the types matches the functionality exposed here

Environment

expo-env-info 1.2.0 environment info:
System:
OS: macOS 14.4.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
Yarn: 3.2.3 - /opt/homebrew/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
Managers:
CocoaPods: 1.11.3 - /Users/lukas/.gem/ruby/3.1.3/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.4, iOS 17.4, macOS 14.4, tvOS 17.4, visionOS 1.1, watchOS 10.4
IDEs:
Android Studio: 2023.2 AI-232.10300.40.2321.11567975
Xcode: 15.3/15E204a - /usr/bin/xcodebuild
npmGlobalPackages:
eas-cli: 7.4.0
Expo Workflow: bare

@ljukas ljukas added needs validation Issue needs to be validated Router expo-router labels Apr 17, 2024
@expo-bot expo-bot added needs review Issue is ready to be reviewed by a maintainer and removed needs validation Issue needs to be validated labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer Router expo-router
Projects
None yet
Development

No branches or pull requests

3 participants