docs: create document describing act function and related errors - #969
Merged
Conversation
BartoszKlonowski
approved these changes
May 12, 2022
BartoszKlonowski
left a comment
Member
There was a problem hiding this comment.
Really good article when it comes to technicals and knowledge, I find it to be detailed and explanatory, but not overwhelming.
I went also through examples by trying them locally 👍
All of my remarks are cosmetic and/or readability concerns - free to merge once covered.
|
|
||
| When wrapping rendering call with `act` we see that the changes caused by `useEffect` hook have been applied as we would expect. | ||
|
|
||
| ### When to use act |
Member
There was a problem hiding this comment.
I'm having a hard time understanding why this is only in "sync" section. How is it when it comes to "async"?
AugustinLF
approved these changes
May 19, 2022
| test('render with real timers - sleep', async () => { | ||
| const view = render(<TestAsyncComponent />); | ||
| await act(async () => { | ||
| await sleep(50 + 10); // Wait a bit longer then setTimeout in component |
Collaborator
There was a problem hiding this comment.
Might be a bit confusing because said component (and initial use of the value 50) is higher in this document and as a reader I'd rather not have to scroll up
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.
Summary
Our users frequently report cryptic errors related to
act()function usage, like #379 or #859. In order to address this I've created Understanding Act function document to describe it's why and how to use it. Consider it to be initial version of the document describing theactbasics, with intention to add more specific information for async act warnings later on.Please share your thoughts and suggestions to improve this document.
Test plan
Docs only
I've run docosaurus and manually verified links and layout.