MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / assertValidProps

Function assertValidProps

examples/simple/react.js:6412–6431  ·  view source on GitHub ↗

* @param {object} component * @param {?object} props

(component, props)

Source from the content-addressed store, hash-verified

6410 * @param {?object} props
6411 */
6412function assertValidProps(component, props) {
6413 if (!props) {
6414 return;
6415 }
6416 // Note the use of `==` which checks for null or undefined.
6417 if ("development" !== 'production') {
6418 if (voidElementTags[component._tag]) {
6419 "development" !== 'production' ? warning(props.children == null && props.dangerouslySetInnerHTML == null, '%s is a void element tag and must not have `children` or ' + 'use `props.dangerouslySetInnerHTML`.%s', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : undefined;
6420 }
6421 }
6422 if (props.dangerouslySetInnerHTML != null) {
6423 !(props.children == null) ? "development" !== 'production' ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : invariant(false) : undefined;
6424 !(typeof props.dangerouslySetInnerHTML === 'object' && '__html' in props.dangerouslySetInnerHTML) ? "development" !== 'production' ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.') : invariant(false) : undefined;
6425 }
6426 if ("development" !== 'production') {
6427 "development" !== 'production' ? warning(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.') : undefined;
6428 "development" !== 'production' ? warning(!props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : undefined;
6429 }
6430 !(props.style == null || typeof props.style === 'object') ? "development" !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)) : invariant(false) : undefined;
6431}
6432
6433function enqueuePutListener(id, registrationName, listener, transaction) {
6434 if ("development" !== 'production') {

Callers 1

react.jsFile · 0.85

Calls 4

getNameMethod · 0.80
invariantFunction · 0.70
warningFunction · 0.50

Tested by

no test coverage detected