Skip to content

Commit 25f6c1f

Browse files
committed
workaround symbol export not working in unit tests
1 parent 49308b9 commit 25f6c1f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/react-reconciler/src/__tests__/useMemoCache-test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
const {REACT_MEMO_CACHE_SENTINEL} = require('shared/ReactSymbols');
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+
* @jest-environment node
9+
*/
210

311
let React;
412
let ReactNoop;
513
let act;
614
let useState;
715
let useMemoCache;
16+
let MemoCacheSentinel;
817
let ErrorBoundary;
918

1019
describe('useMemoCache()', () => {
@@ -16,6 +25,7 @@ describe('useMemoCache()', () => {
1625
act = require('jest-react').act;
1726
useState = React.useState;
1827
useMemoCache = React.unstable_useMemoCache;
28+
MemoCacheSentinel = Symbol.for('react.memo_cache_sentinel');
1929

2030
class _ErrorBoundary extends React.Component {
2131
constructor(props) {
@@ -48,7 +58,8 @@ describe('useMemoCache()', () => {
4858
const cache = useMemoCache(1);
4959
expect(Array.isArray(cache)).toBe(true);
5060
expect(cache.length).toBe(1);
51-
expect(cache[0]).toBe(REACT_MEMO_CACHE_SENTINEL);
61+
expect(cache[0]).toBe(MemoCacheSentinel);
62+
5263
return 'Ok';
5364
}
5465
const root = ReactNoop.createRoot();

packages/react/src/React.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
REACT_SCOPE_TYPE,
2121
REACT_CACHE_TYPE,
2222
REACT_TRACING_MARKER_TYPE,
23-
REACT_MEMO_CACHE_SENTINEL,
2423
} from 'shared/ReactSymbols';
2524

2625
import {Component, PureComponent} from './ReactBaseClasses';
@@ -140,7 +139,6 @@ export {
140139
REACT_CACHE_TYPE as unstable_Cache,
141140
use as experimental_use,
142141
useMemoCache as unstable_useMemoCache,
143-
REACT_MEMO_CACHE_SENTINEL as unstable_MemoCacheSentinel,
144142
// enableScopeAPI
145143
REACT_SCOPE_TYPE as unstable_Scope,
146144
// enableTransitionTracing

0 commit comments

Comments
 (0)