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

Delay snapshot until redux store is re-hydrated #68

Open
jasan-s opened this issue Sep 24, 2017 · 1 comment
Open

Delay snapshot until redux store is re-hydrated #68

jasan-s opened this issue Sep 24, 2017 · 1 comment

Comments

@jasan-s
Copy link

jasan-s commented Sep 24, 2017

I am delaying my main app component render until my store is re-hydrated using redux-persist like so:

  render() {
    const {authed, emailVerified, authedId, location, rehydrationComplete} = this.props
    return (
      <div>
      { rehydrationComplete
       ? <MainContainer>
          <Switch key={location.key} location={location}>
            <Route exact={true} path='/' component={HomeContainer} />
            <Route render={() => <h2> Oops. Page not found. </h2>} />
          </Switch>
      </MainContainer>
      : <div>...Loading </div> }
      </div>
    )
  }

However , even with snapshotDelay of 8200 all the static generated html files from react-snapshot contain only ...Loading . Am I misunderstanding what snapshotDelay option does?

Can i use the Async Branch somehow?

@jasan-s
Copy link
Author

jasan-s commented Sep 25, 2017

I tried the following to delay React-snapshot so that it renders html after the store has been rehydrated:


import {render as snapshotRender} from 'react-snapshot'
import {ConnectedRouter} from 'react-router-redux'

async function init() {
const store = await configureStore()
snapshotRender(
  <Provider store={store}>
    {/* ConnectedRouter will use the store from Provider automatically */}
    <ConnectedRouter history={history}>
      <App />
    </ConnectedRouter>
  </Provider>,
  document.getElementById('root')
)

registerServiceWorker()
}

init()

But now get the error that 'render' from react-snapshot was never called. Did you replace the call to ReactDOM.render()?
I posted it on stackoverflow as well.
Essentially I need to delay the Snapshot render until my store is hydrated? @geelen Any Suggestions?

@jasan-s jasan-s changed the title Using it with redux -persist Using it with redux-persist Oct 4, 2017
@jasan-s jasan-s changed the title Using it with redux-persist Delay snapshot until redux store is re-hydrated Oct 23, 2017
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

1 participant