Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React native navigation param expecting undefined

$
0
0

Im using react native. When I try to navigate and pass prop as outlined in the documentation, the following code gives me this warning indicating that typescript is expecting the 2nd argument to be undefined.

Note that the code does work and I can output the param userId: jane in Test Modal. I am just not sure what this warning/error is about.

Am I doing something wrong or is this just a bug (Since the documentation outlines how to do it quite clearly)

Code:

navigation.navigate('TestModal', { userId: 'jane' })}

Error Message:

Argument of type '["TestModal", { userId: string; }]' is not assignable to parameter of type '[screen: "TestModal"] | [screen: "TestModal", params: undefined]'.  Type '["TestModal", { userId: string; }]' is not assignable to type '[screen: "TestModal", params: undefined]'.    Type at position 1 in source is not compatible with type at position 1 in target.      Type '{ userId: string; }' is not assignable to type 'undefined'.ts(2345)

react native navigation expecting undefined param


Viewing all articles
Browse latest Browse all 6287

Trending Articles