Skip to content

Commit

Permalink
Fix for refs-test
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Feb 6, 2024
1 parent ab75d56 commit d8315a6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/react-dom/src/__tests__/refs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,14 @@ describe('creating element with string ref in constructor', () => {
});

describe('strings refs across renderers', () => {
beforeEach(() => {
React = require('react');
ReactDOMClient = require('react-dom/client');
ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactTestUtils = require('react-dom/test-utils');
act = require('internal-test-utils').act;
});

it('does not break', async () => {
class Parent extends React.Component {
render() {
Expand All @@ -582,10 +590,13 @@ describe('strings refs across renderers', () => {

class Indirection extends React.Component {
componentDidUpdate() {
jest.resetModules();
// One ref is being rendered later using another renderer copy.
const AnotherCopyOfReactDOM = require('react-dom');
const AnotherCopyOfReactDOMClient = require('react-dom/client');
const root = AnotherCopyOfReactDOMClient.createRoot(div2);

// TODO: this should error since flushSync is called in a lifecycle.
AnotherCopyOfReactDOM.flushSync(() => {
root.render(this.props.child2);
});
Expand Down

0 comments on commit d8315a6

Please sign in to comment.