You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting the warning "You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app." However there isn't any getInitialProps in our custom _app.js
import React from "react"
import App from "next/app"
import Head from "next/head"
import { ThemeProvider, createGlobalStyle } from "styled-components"
import { ApolloProvider } from "@apollo/react-hooks"
import withApollo from "../hooks/withApollo"
import { ApolloClient, NormalizedCacheObject } from "apollo-boost"
export interface ITheme {
niceBlack: string;
}
export interface IThemeWrapper {
theme: ITheme;
}
export const theme: ITheme = {
niceBlack: "#001F3F",
}
const GlobalStyle = createGlobalStyle<IThemeWrapper>`
body {
margin: 0 auto;
color: ${props => props.theme.niceBlack};
}
`
// since "apollo" isn't a native Next.js prop we have to declare it's type.
interface IProps {
apollo: ApolloClient<NormalizedCacheObject>;
}
// adds our custom props interface to the generic App base class.
class MyApp extends App<IProps> {
render() {
// instead of creating a client here, we use the rehydrated apollo client provided by our own withApollo provider.
const { Component, pageProps, apollo } = this.props
return (
<React.Fragment>
<Head>
<title>GraphQL Job Board</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
{/* adds the apollo provider to provide it's children with the apollo scope. */}
<ApolloProvider client={apollo}>
<ThemeProvider theme={theme}>
<GlobalStyle />
<Component {...pageProps} />
</ThemeProvider>
</ApolloProvider>
</React.Fragment>
)
}
}
// before exporting our App we wrapp it with our own withApollo provider to have access to the our rehydrated apollo client.
export default withApollo(MyApp)
To Reproduce
Expected behavior
No warnings when running yarn build
Screenshots
The text was updated successfully, but these errors were encountered:
Bug report
Describe the bug
Getting the warning "You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app." However there isn't any getInitialProps in our custom _app.js
To Reproduce
Expected behavior
No warnings when running
yarn build
Screenshots
The text was updated successfully, but these errors were encountered: