MCPcopy Create free account
hub / github.com/reactjs/react-rails / assertValidProps

Function assertValidProps

lib/assets/react-source/development/react.js:8419–8458  ·  view source on GitHub ↗
(tag, props)

Source from the content-addressed store, hash-verified

8417 }
8418
8419 function assertValidProps(tag, props) {
8420 if (!props) {
8421 return;
8422 } // Note the use of `==` which checks for null or undefined.
8423
8424
8425 if (voidElementTags[tag]) {
8426 if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
8427 {
8428 throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) );
8429 }
8430 }
8431 }
8432
8433 if (props.dangerouslySetInnerHTML != null) {
8434 if (!(props.children == null)) {
8435 {
8436 throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." );
8437 }
8438 }
8439
8440 if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) {
8441 {
8442 throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information." );
8443 }
8444 }
8445 }
8446
8447 {
8448 if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
8449 error('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.');
8450 }
8451 }
8452
8453 if (!(props.style == null || typeof props.style === 'object')) {
8454 {
8455 throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) );
8456 }
8457 }
8458 }
8459
8460 function isCustomComponent(tagName, props) {
8461 if (tagName.indexOf('-') === -1) {

Callers 3

setInitialPropertiesFunction · 0.70
diffPropertiesFunction · 0.70
diffHydratedPropertiesFunction · 0.70

Calls 1

errorFunction · 0.70

Tested by

no test coverage detected