mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
* warn when using the wrong renderer's act around another renderer's updates like it says. it uses a real object as the sigil (instead of just a boolean). specifically, it uses a renderer's flushPassiveEffects as the sigil. We also run tests for this separate from our main suite (which doesn't allow loading multiple renderers in a suite), but makes sure to run this in CI as well. * unneeded (and wrong) comment * run the dom fixture on CI * update the sigil only in __DEV__ * remove the obnoxious comment * use an explicit export for the sigil
45 lines
1.3 KiB
HTML
45 lines
1.3 KiB
HTML
<!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="scheduler-unstable_mock.development.js"></script>
|
|
<script src="react.development.js"></script>
|
|
<script type="text/javascript">
|
|
window.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler =
|
|
window.SchedulerMock;
|
|
</script>
|
|
<script src="react-dom.development.js"></script>
|
|
<script src="react-dom-test-utils.development.js"></script>
|
|
<script>
|
|
// 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;
|
|
}
|
|
|
|
async function testAsyncAct() {
|
|
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);
|
|
}
|
|
|
|
testAsyncAct();
|
|
</script>
|
|
</body>
|
|
</html>
|