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

How to use error object in error page component with TypeScript? #56

Open
devopsix opened this issue Feb 28, 2021 · 0 comments · May be fixed by #84
Open

How to use error object in error page component with TypeScript? #56

devopsix opened this issue Feb 28, 2021 · 0 comments · May be fixed by #84

Comments

@devopsix
Copy link

devopsix commented Feb 28, 2021

In a TypeScript project, I'd like to implement an error page like the one from the error page examples:

const NotFound = ({ error }) => (
  <div>
    <h1>Not found.</h1>
    <p>{error}</p>
  </div>
);

// ...

<GuardProvider error={NotFound}>
  // ...
</GuardProvider>

But this results in a TypeScript error:

TS2322: Type '({ error }: { error: any; }) => Element' is not assignable to type 'PageComponent'.
Type '({ error }: { error: any; }) => Element' is not assignable to type 'FunctionComponent<{}>'.
Types of parameters '__0' and 'props' are incompatible.

Am I doing something wrong?

Or does the way PageComponent is defined does not allow this because ComponentType is used without a type variable?

export declare type PageComponent = ComponentType | null | undefined | string | boolean | number;

Any help is much appreciated!

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

Successfully merging a pull request may close this issue.

1 participant