ReactElementValidator-test.internal.js — react Source File
Architecture documentation for ReactElementValidator-test.internal.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
/**
* 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';
// NOTE: We're explicitly not using JSX in this file. This is intended to test
// classic React.createElement without JSX.
// TODO: ^ the above note is a bit stale because there are tests in this file
// that do use JSX syntax. We should port them to React.createElement, and also
// confirm there's a corresponding test that uses JSX syntax.
let React;
let ReactDOMClient;
let act;
let assertConsoleErrorDev;
describe('ReactElementValidator', () => {
let ComponentClass;
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactDOMClient = require('react-dom/client');
({act, assertConsoleErrorDev} = require('internal-test-utils'));
ComponentClass = class extends React.Component {
render() {
return React.createElement('div', null, this.props.children);
}
};
});
it('warns for keys for arrays of elements in rest args', async () => {
const root = ReactDOMClient.createRoot(document.createElement('div'));
await act(() =>
root.render(
React.createElement(ComponentClass, null, [
React.createElement(ComponentClass),
React.createElement(ComponentClass),
]),
),
);
assertConsoleErrorDev([
'Each child in a list should have a unique "key" prop.\n\n' +
'Check the render method of `ComponentClass`. See https://react.dev/link/warning-keys for more information.\n' +
' in ComponentClass (at **)',
]);
});
it('warns for keys for arrays of elements with owner info', async () => {
class InnerClass extends React.Component {
render() {
return React.createElement(ComponentClass, null, this.props.childSet);
}
// ... (472 more lines)
Domain
Subdomains
Source
Frequently Asked Questions
What does ReactElementValidator-test.internal.js do?
ReactElementValidator-test.internal.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
Where is ReactElementValidator-test.internal.js in the architecture?
ReactElementValidator-test.internal.js is located at packages/react/src/__tests__/ReactElementValidator-test.internal.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free