Skip to content

Commit 0f05306

Browse files
committed
Let ReactDOM initialize in RSC
1 parent 71f2c8c commit 0f05306

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed
Lines changed: 22 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ 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 ? new React.Component().refs : {};
8787

8888
let didWarnAboutStateAssignmentForComponent;
8989
let didWarnAboutUninitializedState;

packages/react/react.shared-subset.js

Lines changed: 10 additions & 0 deletions
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)