Skip to content

Bug in nested ReactAsync.Mixin? ("render" called before "getInitialStateAsync") #32

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

Closed
chrisdew opened this issue Sep 22, 2014 · 2 comments

Comments

@chrisdew
Copy link

I've created a repo which shows the odd behaviour: https://github.com/chrisdew/react-quickstart

The problem is that if I click either the link or the button to go to /nesting/users/doe, the NestedUserPage::render is run before (and after) NestedUserPage::getInitialStateAsync.

NestedUserPage::render client.js:125
NestedUserPage::getInitialState client.js:109
NestedUserPage::render client.js:125

In my own code, where it uses Array::map to render lists, this premature rendering produces Uncaught TypeError: Cannot read property 'map' of undefined and stops the site from working.

The un-nested /users/doe works fine, as UserPage::getInitialStateAsync is called before the first UserPage::render.

UserPage::getInitialState client.js:56
UserPage::render 

This may be a bug, or a problem with my understanding.

@andreypopp
Copy link
Owner

From the docs:

Component should provide render() implementation which can render in absence of asynchronous part of the state.

If state is not fetched yet, react-async still renders the component and starts fetching state, then it re-renders component after fetch is complete.

@chrisdew
Copy link
Author

Thanks.

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

2 participants