react/packages/shared/__tests__/ReactSymbols-test.internal.js
Sebastian Markbåge 3b551c8284
Rename the react.element symbol to react.transitional.element (#28813)
We have changed the shape (and the runtime) of React Elements. To help
avoid precompiled or inlined JSX having subtle breakages or deopting
hidden classes, I renamed the symbol so that we can early error if
private implementation details are used or mismatching versions are
used.

Why "transitional"? Well, because this is not the last time we'll change
the shape. This is just a stepping stone to removing the `ref` field on
the elements in the next version so we'll likely have to do it again.
2024-04-22 12:39:56 -04:00

31 lines
772 B
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and 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('ReactSymbols', () => {
beforeEach(() => jest.resetModules());
const expectToBeUnique = keyValuePairs => {
const map = new Map();
keyValuePairs.forEach(([key, value]) => {
if (map.has(value)) {
throw Error(
`${key} value ${value.toString()} is the same as ${map.get(value)}.`,
);
}
map.set(value, key);
});
};
// @gate renameElementSymbol
it('Symbol values should be unique', () => {
expectToBeUnique(Object.entries(require('shared/ReactSymbols')));
});
});