Skip to content
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

PersistGate Type error #731

Open
diegolaciar opened this issue Feb 23, 2018 · 14 comments
Open

PersistGate Type error #731

diegolaciar opened this issue Feb 23, 2018 · 14 comments

Comments

@diegolaciar
Copy link

diegolaciar commented Feb 23, 2018

Hi,

I'm using redux with immutable and redux-persist.

Works good and auto hydrate from the storage to redux store is working. But, when I try to include PersistGate I get this error.

      <Provider store={store}>
        <PersistGate loading={() => <div>LOADING...</div>} persistor={persistor}>
          <RootComponent>
        </PersistGate>
      </Provider>

This is the persistor I set : {rehydrate: ƒ, pause: ƒ, resume: ƒ, purge: ƒ}
Looks the interface is the same as in the documentation.

The error:

Uncaught TypeError: this.props.persistor.subscribe is not a function
    at PersistGate.componentDidMount (react.js?e23e:53)
    at commitLifeCycles (react-dom.development.js:8770)
    at commitAllLifeCycles (react-dom.development.js:9946)
    at HTMLUnknownElement.callCallback (react-dom.development.js:542)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:581)
    at invokeGuardedCallback (react-dom.development.js:438)
    at commitRoot (react-dom.development.js:10050)
    at performWorkOnRoot (react-dom.development.js:11017)
    at performWork (react-dom.development.js:10967)
    at requestWork (react-dom.development.js:10878)

I tried to use PersistGate to solve this issue #732 and i got this error

Thanks,

@thenewt15
Copy link
Contributor

The loading prop takes either null or a component.

@diegolaciar
Copy link
Author

Thanks @thenewt15, but already changed that, the error persist. Write a component or null don' t fix this issue.

@diegolaciar
Copy link
Author

diegolaciar commented Feb 23, 2018

Also note that the Uncaught TypeError expect a subscribe function, as the ".subscribe(listener)" that redux Store have. https://redux.js.org/api-reference/store
Persistor do not have that function.

@rt2zz
Copy link
Owner

rt2zz commented Feb 24, 2018

@diegolaciar it looks like you are using redux-persist v4, but somehow also getting PersistGate which is only available in (and compatible with) v5.

You can read about the upgrade here: https://github.com/rt2zz/redux-persist/blob/master/docs/MigrationGuide-v5.md

However please note there is no top level immutable support in v5. If you need top level immutable you will need to stick to v4 and not use PersistGate

@fntneves
Copy link

fntneves commented Mar 2, 2018

I am experiencing the same issue as @diegolaciar.

@Kannnnng
Copy link

Do you have a plan to support immutable in V5? Thanks to your awesome work : ) @rt2zz

@alburdette619
Copy link

I'm also experiencing this issue and am using redux-persist v5.0.7

@SrujithPoondla
Copy link

I am also experiencing the same issue with redux-persist@5.10.0

@dgaitsgo
Copy link

dgaitsgo commented Jul 2, 2018

idem redux-persist@5.10.0

@TySol
Copy link

TySol commented Jul 18, 2018

same - redux-persist@5.10.0

@heresmyinfo
Copy link

+1 redux-persist@5.10.0

@whydna
Copy link

whydna commented Jul 30, 2018

same issue 5.10

@sebasegura97
Copy link

same issue redux-persist@5.10.0

@bamdadghoori
Copy link

I solved the same problem this way: in store.js instead of

export default () => {
  let store = createStore(persistedReducer)
  let persistor = persistStore(store)
  return { store, persistor }
}

use :

export let store = createStore(persistedReducer)
export let persistor= persistStore(store)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests