Skip to content

Commit 3998c8d

Browse files
committed
Let ReactDOM initialize in RSC
1 parent 71f2c8c commit 3998c8d

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @emails react-core
8+
*/
9+
10+
'use strict';
11+
12+
describe('ReactDOMInReactServer', () => {
13+
beforeEach(() => {
14+
// In RSC this will be aliased.
15+
jest.mock('react', () => require('react/react.shared-subset'));
16+
require('react');
17+
});
18+
19+
it('can require react-dom', () => {
20+
require('react-dom');
21+
});
22+
});

packages/react-reconciler/src/ReactFiberClassComponent.new.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ const fakeInternalInstance = {};
8383

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

8890
let didWarnAboutStateAssignmentForComponent;
8991
let didWarnAboutUninitializedState;

packages/react-reconciler/src/ReactFiberClassComponent.old.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ const fakeInternalInstance = {};
8383

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

8890
let didWarnAboutStateAssignmentForComponent;
8991
let didWarnAboutUninitializedState;

packages/react/react.shared-subset.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
export * from './src/ReactSharedSubset.experimental';

0 commit comments

Comments
 (0)