infinitered / ignite-redux-persist

An Ignite CLI plugin for Redux Persist
9 stars 2 forks source link

Adding PersistGate to boilerplate #15

Closed leonardo2204 closed 5 years ago

leonardo2204 commented 5 years ago

As per the redux-persist docs we can have the following:

import { PersistGate } from 'redux-persist/integration/react'

// ... normal setup, create store and persistor, import components etc.

const App = () => {
  return (
    <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
        <RootComponent />
      </PersistGate>
    </Provider>
  );
};

But in the boilerplates, we persist things inside the Rehydration updateReducers function, which is async.

So, it's kinda tricky to return the persistor from this function and use it later on, because every other callers would have to be async too.

What approach do you think that works best for this use case?

Thanks guys!

ryanlntn commented 5 years ago

@leonardo2204 I'm not really sure as I haven't been using redux a lot lately. I've moved this discussion here since this is actually where we'd need to make changes. There's more info regarding PersistGate here: https://github.com/infinitered/ignite-redux-persist/issues/8

Unfortunately since we don't use redux at IR nearly as much anymore this has been very low priority for us. We would absolutely welcome a PR implementing this though 😄

leonardo2204 commented 5 years ago

@ryanlntn Thank you very much for the other issue, it solved my problem!