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

[ts] Allow making screen params optional #6726

Closed
janicduplessis opened this issue Aug 28, 2019 · 0 comments
Closed

[ts] Allow making screen params optional #6726

janicduplessis opened this issue Aug 28, 2019 · 0 comments

Comments

@janicduplessis
Copy link
Contributor

When defining the type for ParamsList it is not possible to make passing parameters optional. It is only possible to have no parameters at all or some.

Here are some examples to demonstrate:

type RootStackParamsList = {
  screen: undefined,
  screenWithParams: {a: string},
  screenWithOptionalParams: {a?: string} | undefined,
}

navigate('screen') // OK
navigate('screenWithParams', {a: 'a'}) // OK
navigate('screenWithParams') // errors OK
navigate('screenWithOptionalParams', {a: 'a'}) // OK
navigate('screenWithOptionalParams', {}) // OK
navigate('screenWithOptionalParams') // errors but should work.

This means that if screen params are {} | undefined we should allow not passing any parameter to navigate for this screen.

@satya164 satya164 transferred this issue from react-navigation/navigation-ex Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant