Even I tried a lot of thing I couldnt handle that problem... On page load
Problem is : _app.js works twice just onload for all pages..
reactStrictMode is false in next.config.js;
console.log(loading) response 2 times...
I dont understand if it is normal to load twice in nextjs
and here is my Code;
import files;
let Loginstatus = false;
const allEnhancers = compose(
composeWithDevTools(
applyMiddleware(thunk,logger),
)
);
var store = createStore(Mystore,allEnhancers);
store.subscribe(() =>{
console.log('Store updated : ',store.getState())
})
checkLog();
const getData = (val) => {console.log("deneme123")}
function MyApp({ Component, pageProps }) {
const [winWidth, setwinWidth] = useState();
useEffect(() => {
if (typeof window !== 'undefined' && winWidth==null) {
setwinWidth(window.innerWidth);
window.addEventListener('resize', function(event) {
setwinWidth(window.innerWidth);
})
}
}, []);
if(Loginstatus == null || !store || !winWidth ){
return(
<>
<MyLoading/>
</>
)
}
console.log(loading)
return(
<Provider store={store}>
<Header logstatus={Loginstatus} winWidth={winWidth}/>
<Component {...pageProps} logstatus={Loginstatus} winWidth={winWidth}/>
{winWidth >700 ? <Footer logstatus={Loginstatus}/>: null }
</Provider>
)
}
export default MyApp