ReactDOMOption.js — react Source File
Architecture documentation for ReactDOMOption.js, a javascript file in the react codebase. 1 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR b65ed748_8e6c_776b_1a5a_46949ac08a42["ReactDOMOption.js"] ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] b65ed748_8e6c_776b_1a5a_46949ac08a42 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 1e990658_7cea_75be_1f24_2399bdf9f15b["ReactDOMComponent.js"] 1e990658_7cea_75be_1f24_2399bdf9f15b --> b65ed748_8e6c_776b_1a5a_46949ac08a42 style b65ed748_8e6c_776b_1a5a_46949ac08a42 fill:#6366f1,stroke:#818cf8,color:#fff
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.
*
* @flow
*/
import {Children} from 'react';
let didWarnSelectedSetOnOption = false;
let didWarnInvalidChild = false;
let didWarnInvalidInnerHTML = false;
/**
* Implements an <option> host component that warns when `selected` is set.
*/
export function validateOptionProps(element: Element, props: Object) {
if (__DEV__) {
// If a value is not provided, then the children must be simple.
if (props.value == null) {
if (typeof props.children === 'object' && props.children !== null) {
Children.forEach(props.children, function (child) {
if (child == null) {
return;
}
if (
typeof child === 'string' ||
typeof child === 'number' ||
typeof child === 'bigint'
) {
return;
}
if (!didWarnInvalidChild) {
didWarnInvalidChild = true;
console.error(
'Cannot infer the option value of complex children. ' +
'Pass a `value` prop or use a plain string as children to <option>.',
);
}
});
} else if (props.dangerouslySetInnerHTML != null) {
if (!didWarnInvalidInnerHTML) {
didWarnInvalidInnerHTML = true;
console.error(
'Pass a `value` prop if you set dangerouslyInnerHTML so React knows ' +
'which value should be selected.',
);
}
}
}
// TODO: Remove support for `selected` in <option>.
if (props.selected != null && !didWarnSelectedSetOnOption) {
console.error(
'Use the `defaultValue` or `value` props on <select> instead of ' +
'setting `selected` on <option>.',
);
didWarnSelectedSetOnOption = true;
}
}
}
Domain
Subdomains
Functions
Dependencies
- react
Source
Frequently Asked Questions
What does ReactDOMOption.js do?
ReactDOMOption.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactDOMOption.js?
ReactDOMOption.js defines 1 function(s): validateOptionProps.
What does ReactDOMOption.js depend on?
ReactDOMOption.js imports 1 module(s): react.
What files import ReactDOMOption.js?
ReactDOMOption.js is imported by 1 file(s): ReactDOMComponent.js.
Where is ReactDOMOption.js in the architecture?
ReactDOMOption.js is located at packages/react-dom-bindings/src/client/ReactDOMOption.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom-bindings/src/client).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free