Search code examples
typescriptreact-nativedebuggingreact-navigation

react native typescript 'string' is not assignable to parameter of type 'never.' in useNavigation


[I keep getting the error that says 'string' is not assignable to parameter of type 'never' in react native typescript and I don't know why. Can someone help me fix this bug.

Thank you in advance.

code picture

code snippet :

const loadReport = (id: string) => {
    setPostId(id);
    navigation.navigate('Report', {postId: id});
}

I get an underline under 'Report'.


Solution

  • The only solution I found is to apply the type never on the string name.

    const goToContent = () => {
        navigate("Content" as never, {} as never);
    };
    

    I'm not sure it's the best solution but it's work.