when run command build i'm facing with `Warning: You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app`?
By the next's document, this causes all pages to be executed on the server -- disabling Automatic Static Optimization.
Apparently this happens because of the HOC src/utils/with-redux-store
import React from 'react';
import configureStore from './configure-store';
const isServer = typeof window === 'undefined';
const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__';
function getOrCreateStore(initialState) {
if (isServer) {
return configureStore(initialState);
}
if (!window[__NEXT_REDUX_STORE__]) {
window[__NEXT_REDUX_STORE__] = configureStore(initialState);
}
return window[__NEXT_REDUX_STORE__];
}
export default App => {
return class Redux extends React.Component {
static async getInitialProps(appContext) {
const reduxStore = getOrCreateStore({});
appContext.ctx.reduxStore = reduxStore;
let appProps = {};
if (App.getInitialProps) {
appProps = await App.getInitialProps(appContext);
}
return {
...appProps,
initialReduxState: reduxStore.getState(),
};
}
constructor(props) {
super(props);
// eslint-disable-next-line react/prop-types
this.reduxStore = getOrCreateStore(props.initialReduxState);
}
render() {
return <App {...this.props} reduxStore={this.reduxStore} />;
}
};
};
@cuongdevjs the same topic is discussed here could help.
This error cause ignores auto-optimation mode of next. These pages to have no getInitialProps should be built as static HTML site but built as SSR. :)
I'm facing this error when run command start:

@cuongdevjs This is happening by doing the steps of yarn build and yarn start?
@cuongdevjs This is happening by doing the steps of
yarn buildandyarn start?
Exactly. I don't know why this happens?