I have following code:
import axios from 'axios'
import type { NextPage } from 'next'
import type { AppProps } from 'next/app'
import { ReactElement, ReactNode, useEffect } from 'react'
import { Provider } from 'react-redux'
import Layout from '../components/Layout'
import { setAuthnRes } from '../slices/User'
import { store } from '../store'
import '../styles/globals.scss'
import { baseURL } from '../utils/baseURL'
type NextPageWithLayout = NextPage & {
getLayout?: (page: ReactElement) => ReactNode
}
type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout
}
axios.defaults.baseURL = baseURL(
process.env.NEXT_PUBLIC_ENVIRONMENT ?? 'local',
true
)
axios.defaults.withCredentials = true
function MyApp({ Component, pageProps }: AppPropsWithLayout) {
const dispatch = store.dispatch
const authnUserResp = store.getState().authnUser?.resp
const getLayout = Component.getLayout ?? ((page) => <Layout>{page}</Layout>)
return (
<Provider store={store}>{getLayout(<Component {...pageProps} />)}</Provider> // <------ HERE
)
}
export default MyApp
And I get this:
No overload matches this call.
Overload 1 of 2, '(props: ProviderProps<AnyAction> | Readonly<ProviderProps<AnyAction>>): Provider<AnyAction>', gave the following error.
Type 'React.ReactNode' is not assignable to type 'import("/Users/kukodajanos/Workspace/Tikex/Portal/Team/node_modules/@types/styled-jsx/node_modules/@types/react/index").ReactNode'.
Type '{}' is not assignable to type 'ReactNode'.
Overload 2 of 2, '(props: ProviderProps<AnyAction>, context: any): Provider<AnyAction>', gave the following error.
Type 'React.ReactNode' is not assignable to type 'import("/Users/kukodajanos/Workspace/Tikex/Portal/Team/node_modules/@types/styled-jsx/node_modules/@types/react/index").ReactNode'.ts(2769)
in this line:
<Provider store={store}>{getLayout(<Component {...pageProps} />)}</Provider>
I did a yarn cache clean
getLayout?that causes the error?Componentkeyword with the same'Component' cannot be used as a JSX component.12.1.0and cleaned all node_modules, and problem disappeared