6

I have started to use TypeScript in my React-Native project

My linter doesn't like function as a type, how can I refactor my hoc to pass my linter?

AppNavigator:

const withHeader = (
    screen: Function,
    routeName: string,
    Header,
): StackNavigator =>
    createStackNavigator(
        {
            [routeName]: {
                screen,
                navigationOptions: ({routeName, props}) => ({
                    header: props => <Header {...props} />,
                }),
            },
        },
        {
            initialRoute: 'Home',
            cardStyle: {
                backgroundColor: 'transparent',
                opacity: 1,
            },
            transitionConfig: () => ({
                containerStyle: {
                    backgroundColor: 'transparent',
                },
            }),
        },
    );

My packager also gives me an error with the same file:

error: bundling failed: Error: Unable to resolve module `./navigation/AppNavigator` from `C:\Users\Matt\sites\IAapp\App.tsx`: The module `./navigation/AppNavigator` could not be found from `C:\Users\Matt\sites\IAapp\App.tsx`. Indeed, none of these files exist:
4
  • 1
    Type it as a more specific function () => {}. Function is any of functions. Commented Feb 6, 2020 at 13:54
  • 1
    I have changed that, linter still gives me the same error Commented Feb 6, 2020 at 14:15
  • What specifically do you mean by "my linter doesn't like" it? I think for this to be a minimal reproducible example as described in How to Ask, you should provide the specific error about Function and where it occurs, and what your linter config looks like. Enough for someone to diagnose. Otherwise it'll be hard to advise. Oh, and the error at the bottom seems to be a separate question, right? Commented Feb 6, 2020 at 15:40
  • check if this answers your first question stackoverflow.com/questions/29689966/… Commented Jan 8, 2021 at 6:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.