fixes async setState calls with ssr#54
Merged
jamiebuilds merged 1 commit intojamiebuilds:masterfrom Sep 19, 2017
Merged
Conversation
- Correctly checks whether component has already loaded or not in componentWillMount.
|
Would be great to see this merged to eliminate this warning on server rendering. 🙏
|
|
Are you planning to merge this change? It eliminates the error mentioned above gracefully. |
|
@tajo @thejameskyle can you release a new version with this patch? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
componentWillMount.With SSR,
componentWillMountwas registering somesetTimeoutcallbacks, callingsetStateasynchronously etc. This PR fixes it.As far as I can see,
res.resolvedis never assigned to any value so it's always falsy. WhencomponentWillMountis trigged; ifloadingis false, there's no point in doing the rest of the stuff. Because eitherloadedorerrormust be defined, so one of them can be rendered.BTW, I have a suggestion for another PR:
loadingis a computable value:loading === !loaded && !error. So it makes sense to turn it into a computed value to reduce possible mistakes later on.