Skip to content

Commit d8315a6

Browse files
committed
Fix for refs-test
1 parent ab75d56 commit d8315a6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/react-dom/src/__tests__/refs-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,14 @@ describe('creating element with string ref in constructor', () => {
567567
});
568568

569569
describe('strings refs across renderers', () => {
570+
beforeEach(() => {
571+
React = require('react');
572+
ReactDOMClient = require('react-dom/client');
573+
ReactFeatureFlags = require('shared/ReactFeatureFlags');
574+
ReactTestUtils = require('react-dom/test-utils');
575+
act = require('internal-test-utils').act;
576+
});
577+
570578
it('does not break', async () => {
571579
class Parent extends React.Component {
572580
render() {
@@ -582,10 +590,13 @@ describe('strings refs across renderers', () => {
582590

583591
class Indirection extends React.Component {
584592
componentDidUpdate() {
593+
jest.resetModules();
585594
// One ref is being rendered later using another renderer copy.
586595
const AnotherCopyOfReactDOM = require('react-dom');
587596
const AnotherCopyOfReactDOMClient = require('react-dom/client');
588597
const root = AnotherCopyOfReactDOMClient.createRoot(div2);
598+
599+
// TODO: this should error since flushSync is called in a lifecycle.
589600
AnotherCopyOfReactDOM.flushSync(() => {
590601
root.render(this.props.child2);
591602
});

0 commit comments

Comments
 (0)