Reputation: 218
I'm using NextJS with Typescript and when I try to build the code I get the following error in the _app.tsx file:
Property 'Component' does not exist on type 'App<{}, {}, {}>'.
I get Component from AppProps type ('next/app'), this is the code:
import React from "react";
import { CssBaseline } from "@material-ui/core";
import { ThemeProvider } from "@material-ui/core/styles";
import theme from "../themes";
import AppProps from "next/app";
export default function MyApp({ Component, pageProps }: AppProps) {
return (
<ThemeProvider theme={theme}>
<CssBaseline />
<Component {...pageProps} />
</ThemeProvider>
);
}
Any thoughts?
Upvotes: 1
Views: 5547
Reputation: 86
AppProps should been impoted from "next/app" as a normal export, not as a default one. Here is an example of it:
import '../styles/globals.css';
import { AppProps } from 'next/app';
function MyApp( { Component, pageProps }: AppProps ) {
return <Component {...pageProps} />;
}
Note the "{ }" symbols around AppProps import.
Hope this helps you!
Upvotes: 3