-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added a note about using suspension #3410
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Looks good, just one comment
Also, CI needs to be fixed.
website/docs/concepts/suspense.mdx
Outdated
The latter is the one responsible for signaling when to re-render the suspended components, it provides 2 interchangable ways to do so: | ||
1. Calling its [`resume`](https://docs.rs/yew/latest/yew/suspense/struct.SuspensionHandle.html#method.resume) method. | ||
2. Dropping the handle. | ||
If the handle isn't stored for longer than the hook's scope, the suspended components will be constantly re-rendered as often as possible, thus hampering performance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would highlight the infinite loop possibility in :::danger
.
Danger
The handle must be stored until it's time to render the component. Not doing so could lead to infinite loops
You can word it better for it to go along with the rest of the section
Visit the preview URL for this PR (updated for commit 0de5e3a): https://yew-rs--pr3410-fix-suspense-docs-51br2ehe.web.app (expires Sat, 30 Sep 2023 13:37:52 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
otherwise, the suspended components will enter an infinite re-render loop, thus hampering performance. | ||
In the example above, the suspension handle is preserved by being moved into a closure and passed into `on_load_user_complete`. | ||
When the hypothetical user will be loaded, the closure will be called, thus calling `handle.resume()` and re-rendering the components associated with the suspension context. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:::
An additional pair of colons are needed at the end of the admonitions.
2. Dropping the handle. | ||
|
||
:::danger | ||
The suspension handle must be stored until it's time to update components, i.e. with newly received data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be a new line after this. See the link docs about using admonitions with prettier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good!
Description
Added a mention of the requirement to store the suspension handle to the
Yew Docs on suspense
Fixes #2571
Checklist