1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27import * as React from 'react';
import PropTypes from 'prop-types';
function TestViewer(props) {
const { children } = props;
// We're simulating `act(() => ReactDOM.render(children))`
// In the end children passive effects should've been flushed.
// React doesn't have any such guarantee outside of `act()` so we're approximating it.
const [ready, setReady] = React.useState(false);
React.useEffect(() => {
setReady(true);
}, []);
return (
<div aria-busy={!ready} data-testid="testcase">
{children}
</div>
);
}
TestViewer.propTypes = {
children: PropTypes.node.isRequired,
};
export default TestViewer;