question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning after moving to version 6.0.0-rc.8

See original GitHub issue

Using dependencies

  • “next-redux-wrapper”: “^6.0.0-rc.8”
  • “redux”: “^4.0.5”
  • “redux-persist”: “^6.0.0”
  • “next”: “^9.3.5”
  • “react-redux”: “^7.2.0”

I’m using a custom _app.js in the project. after upgrading to version 6.0.0-rc.8 next app is failed to build because of store object is undefined in render() method. After adding try:catch block for render method as below it worked. But getting below messages

[both server side and client side] /!\ You are using legacy implementaion. Please update your code: use createWrapper() and wrapper.withRedux().

[server side only] Unexpected keys "AppTree", "Component", "router", "ctx" found in preloadedState argument passed to createStore. Expected to find one of the known reducer keys instead: "foo", "authentication". Unexpected keys will be ignored.

Also seems like everything works well after using try:catch. am I doing something wrong here?

_app.js

import React from 'react';
import { makeStore } from "../redux/index";
import { Provider } from 'react-redux';
import App from "next/app";
import withRedux from 'next-redux-wrapper';
import { checkServerSideCookie } from '../redux/actions/authActions';
import { PersistGate } from 'redux-persist/integration/react';
import { Router } from "next/router";

class MyApp extends App {

  constructor(props) {
    super(props);
  }

  static async getInitialProps({ Component, ctx }) {
    checkServerSideCookie(ctx);
    const pageProps = Component.getInitialProps ? await Component.getInitialProps(ctx) : {};
    return { pageProps };
  }

  render() {
    const { Component, pageProps, store } = this.props;
    try {
      return (
        <Provider store={store}>
          <PersistGate persistor={store.__PERSISTOR} loading={null}>
            <Component {...pageProps} />
          </PersistGate>
        </Provider>
      )
    } catch(e) {
      return <Component {...pageProps} />
    }
  }

}

export default withRedux(makeStore)(MyApp);

redux/index.js

import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import thunk from 'redux-thunk';
import rootReducer from './reducers/index';

export const makeStore = (initialState, options) => {
  let store;
  const isClient = typeof window !== 'undefined';

  if (isClient) {
    const { persistStore, persistReducer } = require('redux-persist');
    const storage = require('redux-persist/lib/storage').default;

    const persistConfig = {
      key: 'root',
      storage
    };

    store = createStore(persistReducer(persistConfig, rootReducer),
      initialState,
      composeWithDevTools(applyMiddleware(thunk)));

    store.__PERSISTOR = persistStore(store);

  } else {
    store = createStore(
      rootReducer,
      initialState,
      composeWithDevTools(applyMiddleware(thunk))
    );
  }

  return store;
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
Alexander2317commented, Oct 8, 2020

@neerajincaendo, @infahash, @kirill-konshin This happened because you added initialState parameter to createStore

createStore(reducer, **initialState**, enhancers)

I had exactly the same problem and fixed it by removing initialState from createStore.

I think next.js has its own parameters like "AppTree", "Component", "router", "ctx" and when we write initialState in createStore, we overwrite them.

@kirill-konshin try to check it.

1reaction
justirva09commented, Oct 17, 2020

@Alexander2317 Ahh I see, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need to Update EF Core Tools - Stack Overflow
When running the command whitout specifying any version i got the following error: Tool 'dotnet-ef' failed to update due to the following: The ......
Read more >
Storage Migration Service known issues - Microsoft Learn
Known issues and troubleshooting support for Storage Migration Service, such as how to collect logs for Microsoft Support.
Read more >
How To Update Angular CLI To Latest Version
First update to Angular CLI 6 version and then Angular CLI 7 ==> Angular CLI 8 and finally Angular CLI 9 version. Update...
Read more >
List of upcoming changes for TinyMCE 6 | Docs
This page lists the upcoming changes planned and announced for TinyMCE 6.0, including features that are deprecated and marked for removal. TinyMCE 6.0...
Read more >
AngularJS: Developer Guide: Migrating from Previous Versions
Most apps should not be affected, as "change" is automatically fired by browsers after "click" happens. Two scenarios might need migration:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found