-
Notifications
You must be signed in to change notification settings - Fork 46
Conversation
You might not want to update them all!
You might not want to update all
Hi @Titozzz The To me this won't change anything, do you see any case that might differ before/after? I've made a playground here: http://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=18&pc=36#code/JYOwLgpgTgZghgYwgAgHJwG7AOZzMAexAAU4o4BbAZ2QG8AoZZAbQGsIBPALmSrClDYAujzggOAbnoBfevQRE+vCGFLlqARmQBeZAAoADmUpUA-D3RZc+ImpMBKHQD46yWQpBKqKu9QBMOvpG6mY8avhwADYAPJY4eIQkxtROjtoutG5y3qrJVBp69lI5vlR+hVL0JXkFtNJFVT555XUNjbkhtVQEFBC+PBr1xU0hLd29-ciDbdWderTjfck8AK4gACYQMKAQ60PtpWM9S+qrG1s7e0VAA |
Maybe the fix is wrong. Is the issue I was facing. |
But I didn't check where the generic is used so I'll have another look |
The file I'd need to be updated is I'd need setParams to be export declare type NavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = string, State extends NavigationState = NavigationState, ScreenOptions extends object = {}, EventMap extends Record<string, any> = {}> = NavigationHelpersCommon<ParamList, State> & {
/**
* Update the param object for the route.
* The new params will be shallow merged with the old one.
*
* @param params Params object for the current route.
*/
setParams(params: ParamList[RouteName]): void;
/**
* Update the options for the route.
* The options object will be shallow merged with default options object.
*
* @param options Options object for the route.
*/
setOptions(options: Partial<ScreenOptions>): void;
/**
* Returns the parent navigator, if any. Reason why the function is called
* dangerouslyGetParent is to warn developers against overusing it to eg. get parent
* of parent and other hard-to-follow patterns.
*/
dangerouslyGetParent<T = NavigationProp<ParamListBase> | undefined>(): T;
/**
* Returns the navigator's state. Reason why the function is called
* dangerouslyGetState is to discourage developers to use internal navigation's state.
* Note that this method doesn't re-render screen when the result changes. So don't use it in `render`.
*/
dangerouslyGetState(): State;
} & EventConsumer<EventMap & EventMapBase> & PrivateValueStore<ParamList, RouteName, EventMap>; |
So if I understand correctly what you do is something like: const MyScreen = ({navigation}: {navigation: NavigationProp<{p1: string, p2: string>}>) => {
// this work
const handleEvent = () => navigation.setParams({p1: "x",p2: "y"});
// this fail
const handleEvent = () => navigation.setParams({p1: "x"});
return ...
} ??? |
Hey @Titozzz! Seems like you're using v5. This is not the correct repo. The code is here https://github.com/react-navigation/navigation-ex |
🤦♂ |
You might not want to update all params?
I'm open to discussing this as I don't know if this was intentional or not :)