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
when run command build i'm facing with Warning: You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app
?
#58
Comments
Warning: You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app
? I am looking for a solution to fixing this? Warning: You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app
?
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. |
@cuongdevjs This is happening by doing the steps of |
Exactly. I don't know why this happens? |
By the next's document, this causes all pages to be executed on the server -- disabling Automatic Static Optimization.
The text was updated successfully, but these errors were encountered: