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

Component attempts to render before asyncConnect promise is fired/resolved #136

Open
simonurmi opened this issue May 17, 2019 · 0 comments

Comments

@simonurmi
Copy link

simonurmi commented May 17, 2019

I'm exporting my component as follows:

export default asyncConnect([{ promise: loadAsyncProps }])(
  connect(
    mapStateToProps,
    mapDispatchToProps,
  )(MyComponent),
);

And using it in router config like this:

[
  {
    path: '/',
    component: Root,
    routes: [
      {
        path: '/',
        exact: true,
        component: Home,
      },
      {
        path: '/my-route',
        exact: true,
        component: MyAsyncConnectedComponent,
      },
  },
];

Home component doesn't use asyncConnect. It works fine. MyComponent works only when clicking to /my-route through a link in Home.

When entering /my-route in any other way (address bar, hot reload etc.), the inner component, in this case the react-redux connected MyComponent, is rendered without the promise even firing.

MyComponent uses data fetched with asyncConnect, and the component crashes because props are null.

I'm not using SSR.

Library versions:

redux-connect: 9.0.0
react-redux: 7.0.0
react-router: 5.0.0
react: 16.8.6
redux: 4.0.1
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