redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

PersistGate Type error

Open diegolaciar opened this issue 7 years ago • 14 comments

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 https://github.com/rt2zz/redux-persist/issues/732 and i got this error

Thanks,

diegolaciar avatar Feb 23 '18 19:02 diegolaciar

The loading prop takes either null or a component.

thenewt15 avatar Feb 23 '18 20:02 thenewt15

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

diegolaciar avatar Feb 23 '18 22:02 diegolaciar

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.

diegolaciar avatar Feb 23 '18 22:02 diegolaciar

@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

rt2zz avatar Feb 24 '18 05:02 rt2zz

I am experiencing the same issue as @diegolaciar.

fntneves avatar Mar 02 '18 19:03 fntneves

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

Kannnnng avatar May 21 '18 02:05 Kannnnng

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

alburdette619 avatar Jun 20 '18 19:06 alburdette619

I am also experiencing the same issue with [email protected]

SrujithPoondla avatar Jun 23 '18 04:06 SrujithPoondla

idem [email protected]

dgaitsgo avatar Jul 02 '18 17:07 dgaitsgo

same - [email protected]

TySol avatar Jul 18 '18 00:07 TySol

+1 [email protected]

heresmyinfo avatar Jul 29 '18 16:07 heresmyinfo

same issue 5.10

whydna avatar Jul 30 '18 00:07 whydna

same issue [email protected]

sebasegura97 avatar Sep 17 '18 15:09 sebasegura97

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)

bamdadghoori avatar May 18 '22 05:05 bamdadghoori