MCPcopy Index your code
hub / github.com/microsoft/SandDance / validateProps

Function validateProps

docs/external/js/react-dom.development.js:2211–2246  ·  view source on GitHub ↗

* Implements an host component that warns when `selected` is set.

(element, props)

Source from the content-addressed store, hash-verified

2209
2210
2211 function validateProps(element, props) {
2212 {
2213 // This mirrors the codepath above, but runs for hydration too.
2214 // Warn about invalid children here so that client and hydration are consistent.
2215 // TODO: this seems like it could cause a DEV-only throw for hydration
2216 // if children contains a non-element object. We should try to avoid that.
2217 if (typeof props.children === 'object' && props.children !== null) {
2218 React.Children.forEach(props.children, function (child) {
2219 if (child == null) {
2220 return;
2221 }
2222
2223 if (typeof child === 'string' || typeof child === 'number') {
2224 return;
2225 }
2226
2227 if (typeof child.type !== 'string') {
2228 return;
2229 }
2230
2231 if (!didWarnInvalidChild) {
2232 didWarnInvalidChild = true;
2233
2234 error('Only strings and numbers are supported as <option> children.');
2235 }
2236 });
2237 } // TODO: Remove support for `selected` in <option>.
2238
2239
2240 if (props.selected != null && !didWarnSelectedSetOnOption) {
2241 error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
2242
2243 didWarnSelectedSetOnOption = true;
2244 }
2245 }
2246 }
2247 function postMountWrapper$1(element, props) {
2248 // value="" should make a value attribute (#6219)
2249 if (props.value != null) {

Callers 2

setInitialPropertiesFunction · 0.70
diffHydratedPropertiesFunction · 0.70

Calls 2

errorFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected