-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
await act(async () => ...) #14853
Merged
Merged
await act(async () => ...) #14853
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
9791a6b
hacked up act(async () => {...})
49876c3
move stuff around
d16525a
Merge remote-tracking branch 'upstream/master' into async-act
0a1b308
Merge remote-tracking branch 'upstream/master' into async-act
5cf26ba
merge changes
d2ea31e
abstract .act warnings and stuff. all renderers. pass all tests.
c7e07c7
Merge remote-tracking branch 'upstream/master' into async-act
3c4142b
move testutils.act back into testutils
331d9eb
move into scheduler, rename some bits
d0daebf
smaller bundle
00c2fd6
a comment for why we don't do typeof === 'function'
788fd73
fix test
cd2f191
pass tests - fire, prod
6af7e80
lose actContainerElement
a8fb80b
tighter
955d590
write a test for TestRenderer
ee8086a
lint
441e597
rewrote to move flushing logic closer to the renderer
c07174b
move it around so the delta isn't too bad
95bffdf
Merge remote-tracking branch 'upstream/master' into async-act
0fe5318
cleanups
c0a4573
Stray comment
1b1a896
recursively flush effects
06d8391
Merge branch 'async-act' of github.com:threepointone/react into async…
6c2bcc5
Merge remote-tracking branch 'upstream/master' into async-act
3028209
fixed tests
7da103b
lint, move noop.act into react-reconciler
cc51fca
microtasks when checking if called, s/called/calledLog, cleanup
91a3ff4
pass fb lint
a5e84e2
Merge remote-tracking branch 'upstream/master' into async-act
8688517
shorter timers, fix a test, test for Promise
308d14f
use global.Promise for existence check
edfafa5
Merge remote-tracking branch 'upstream/master' into async-act
13f43fd
Merge remote-tracking branch 'upstream/master' into async-act
6283cf4
flush microtasks
38bf178
a version that works in browsers (that support postMessage)
ab521ce
hoist flushEffectsAndMicroTasks
ae46998
pull out tick logic from ReactFiberScheduler
2779bae
fix await act (...sync) hanging
d36b8d5
feedback changes
3766812
pass lint/flow checks (without requiring a Promise polyfill/exclusion)
f66ed55
Merge remote-tracking branch 'upstream/master' into async-act
ad55c26
prettier
a29f008
use globalPromise for the missed await warning
a777344
__DEV__ check for didWarnAboutMessageChannel
aa37d51
thenables and callbacks instead of promises, pass flow/lint
c4afc5f
tinier. better.
7998527
pass build validation
e37602b
augh prettier
58ecb21
golfing 7 more chars
04a4e91
Test that effects are not flushed without also flushing microtasks
acdlite cdcbc7c
Merge remote-tracking branch 'upstream/master' into async-act
6a8cc02
Merge branch 'async-act' of github.com:threepointone/react into async…
429bda2
export doesHavePendingPassiveEffects, nits
adc92b4
createAct()
c1ee84e
dead code
53d3fbf
Merge remote-tracking branch 'upstream/master' into async-act
ad548b5
missed in merge?
8e4ea16
Merge remote-tracking branch 'upstream/master' into async-act
573a991
lose the preflushing bits
91d40cd
ugh prettier
c97cee4
removed `actedUpdates()`, created shared/actingUpdatesScopeDepth
65d9d0c
Merge remote-tracking branch 'upstream/master' into async-act
efffcb4
rearrange imports so builds work, remove the hack versions of flushPa…
d01d0c9
represent actingUpdatesScopeDepth as a tuple [number]
8737f7d
use a shared flag on React.__SECRET...
5a9081a
remove createAct, setup act for all relevant renderers
44236c9
review feedback
068561a
move act() implementation into createReactNoop
abf1e3a
Merge remote-tracking branch 'upstream/master' into async-act
e49e043
warnIfNotCurrentlyActingUpdatesInDev condition check order
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>sanity test for ReactTestUtils.act</title> | ||
</head> | ||
<body> | ||
this page tests whether act runs properly in a browser. | ||
<br/> | ||
your console should say "5" | ||
<script src='react.development.js'></script> | ||
<script src='react-dom.development.js'></script> | ||
<script src='react-dom-test-utils.development.js'></script> | ||
<script> | ||
async function run(){ | ||
// from ReactTestUtilsAct-test.js | ||
function App() { | ||
let [state, setState] = React.useState(0); | ||
async function ticker() { | ||
await null; | ||
setState(x => x + 1); | ||
} | ||
React.useEffect( | ||
() => { | ||
ticker(); | ||
}, | ||
[Math.min(state, 4)], | ||
); | ||
return state; | ||
} | ||
const el = document.createElement('div'); | ||
await ReactTestUtils.act(async () => { | ||
ReactDOM.render(React.createElement(App), el); | ||
}); | ||
// all 5 ticks present and accounted for | ||
console.log(el.innerHTML); | ||
} | ||
run(); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains 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
Oops, something went wrong.
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.
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.
moved these tests into a separate file for .act tests