Skip to content

Commit

Permalink
Let ReactDOM initialize in RSC
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Oct 18, 2022
1 parent 71f2c8c commit 0f05306
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMInReactServer-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/

'use strict';

describe('ReactDOMInReactServer', () => {
beforeEach(() => {
// In RSC this will be aliased.
jest.mock('react', () => require('react/react.shared-subset'));
require('react');
});

it('can require react-dom', () => {
require('react-dom');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const fakeInternalInstance = {};

// React.Component uses a shared frozen object by default.
// We'll use it to determine whether we need to initialize legacy refs.
export const emptyRefsObject: $FlowFixMe = new React.Component().refs;
export const emptyRefsObject: $FlowFixMe = React.Component ? new React.Component().refs : {};

let didWarnAboutStateAssignmentForComponent;
let didWarnAboutUninitializedState;
Expand Down
10 changes: 10 additions & 0 deletions packages/react/react.shared-subset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export * from './src/ReactSharedSubset.experimental';

0 comments on commit 0f05306

Please sign in to comment.