-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Use async/await in getDerivedStateFromProps #13541
Comments
Your expected is how React outputs today. See https://jsfiddle.net/heaven_xz/Luktwrdm/1155/ , to be honest, this is not about React, it's just a common javascript function call, so how javascript works, how React works. And on the other hand, you have 2 mistakes here:
|
Don't use You want to put this logic into |
@gaearon
Thanks, |
You can't load initial data asynchronously in the current SSR implementation. Think about it: There are unofficial workarounds like rendering twice. We don't recommend that but I understand if you want to do it. In this case you can use the constructor. In the future, it will be possible to wait for data to load using the server renderer. We're tracking this in #1739. I expect that we might have something for this next year. |
@gaearon gotcha, thank you. |
@gaearon Next year? So the SSR suspense won't be released with the client Suspense? |
Client implementation is more or less ready. The cache provider still needs work but the core implementation is already in production at FB. We're just starting work on the SSR part. So it might come later. |
Oh, gotcha, I will notice the issues/prs, hope I could do any helps :) |
Yes, but if I update the state in the |
Are you referring to the behaviour that is answered in the doc https://reactjs.org/docs/react-component.html#componentdidupdate :
In which case, there is your answer. |
Hi
I'm in need of aysnc/await in getDerivedStateFromProps but it's not working as expected.
Expected
Results:
Can't we use async/await in getDerivedStateFromProps?
Thanks,
The text was updated successfully, but these errors were encountered: