setProp() — react Function Reference
Architecture documentation for the setProp() function in ReactDOMComponent.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 5a792874_dbaf_1dd0_9e62_d6a16580e0b5["setProp()"] 1e990658_7cea_75be_1f24_2399bdf9f15b["ReactDOMComponent.js"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|defined in| 1e990658_7cea_75be_1f24_2399bdf9f15b 96cf114b_9b89_b174_432c_1584a973fcdd["setInitialProperties()"] 96cf114b_9b89_b174_432c_1584a973fcdd -->|calls| 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 336b5c16_66c9_7089_05c5_2ec95eb7ed11["updateProperties()"] 336b5c16_66c9_7089_05c5_2ec95eb7ed11 -->|calls| 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 9805d2a0_a12e_fb58_a873_c63b02425b81["validateTextNesting()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| 9805d2a0_a12e_fb58_a873_c63b02425b81 05a2c649_61ae_abc9_51e9_4bae6eb065ff["setTextContent()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| 05a2c649_61ae_abc9_51e9_4bae6eb065ff ff83d1d6_04b2_f2c3_24b2_6ffa36a99dd8["setValueForKnownAttribute()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| ff83d1d6_04b2_f2c3_24b2_6ffa36a99dd8 236c422d_d866_d548_e097_3cec99530791["setValueForStyles()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| 236c422d_d866_d548_e097_3cec99530791 8234e051_6c96_9381_5d63_a81ad81ddbaf["setSrcObject()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| 8234e051_6c96_9381_5d63_a81ad81ddbaf e91f29d2_3f93_a53d_cd2f_ef8a29c2636f["validateFormActionInDevelopment()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| e91f29d2_3f93_a53d_cd2f_ef8a29c2636f b98b4c7e_a5fc_744a_2478_0278e64cf8e0["warnForInvalidEventListener()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| b98b4c7e_a5fc_744a_2478_0278e64cf8e0 a0421d9a_64b7_2b13_1226_e3a3b9292e4e["trapClickOnNonInteractiveElement()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| a0421d9a_64b7_2b13_1226_e3a3b9292e4e 9a006a44_c580_470b_507b_17fea64729bd["listenToNonDelegatedEvent()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| 9a006a44_c580_470b_507b_17fea64729bd b75892dd_dacd_d978_2b97_090839521b0e["setValueForAttribute()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| b75892dd_dacd_d978_2b97_090839521b0e 442618bc_3428_a2b9_4084_a722c28117bc["setValueForNamespacedAttribute()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| 442618bc_3428_a2b9_4084_a722c28117bc style 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/client/ReactDOMComponent.js lines 384–982
function setProp(
domElement: Element,
tag: string,
key: string,
value: mixed,
props: any,
prevValue: mixed,
): void {
switch (key) {
case 'children': {
if (typeof value === 'string') {
if (__DEV__) {
validateTextNesting(value, tag, false);
}
// Avoid setting initial textContent when the text is empty. In IE11 setting
// textContent on a <textarea> will cause the placeholder to not
// show within the <textarea> until it has been focused and blurred again.
// https://github.com/facebook/react/issues/6731#issuecomment-254874553
const canSetTextContent =
tag !== 'body' && (tag !== 'textarea' || value !== '');
if (canSetTextContent) {
setTextContent(domElement, value);
}
} else if (typeof value === 'number' || typeof value === 'bigint') {
if (__DEV__) {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
validateTextNesting('' + value, tag, false);
}
const canSetTextContent = tag !== 'body';
if (canSetTextContent) {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
setTextContent(domElement, '' + value);
}
} else {
return;
}
break;
}
// These are very common props and therefore are in the beginning of the switch.
// TODO: aria-label is a very common prop but allows booleans so is not like the others
// but should ideally go in this list too.
case 'className':
setValueForKnownAttribute(domElement, 'class', value);
break;
case 'tabIndex':
// This has to be case sensitive in SVG.
setValueForKnownAttribute(domElement, 'tabindex', value);
break;
case 'dir':
case 'role':
case 'viewBox':
case 'width':
case 'height': {
setValueForKnownAttribute(domElement, key, value);
break;
}
case 'style': {
setValueForStyles(domElement, value, prevValue);
return;
}
// These attributes accept URLs. These must not allow javascript: URLS.
case 'data':
if (tag !== 'object') {
setValueForKnownAttribute(domElement, 'data', value);
break;
}
// fallthrough
case 'src': {
if (enableSrcObject && typeof value === 'object' && value !== null) {
// Some tags support object sources like Blob, File, MediaSource and MediaStream.
if (tag === 'img' || tag === 'video' || tag === 'audio') {
try {
setSrcObject(domElement, tag, value);
break;
} catch (x) {
// If URL.createObjectURL() errors, it was probably some other object type
// that should be toString:ed instead, so we just fall-through to the normal
// path.
}
} else {
if (__DEV__) {
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does setProp() do?
setProp() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMComponent.js.
Where is setProp() defined?
setProp() is defined in packages/react-dom-bindings/src/client/ReactDOMComponent.js at line 384.
What does setProp() call?
setProp() calls 11 function(s): listenToNonDelegatedEvent, setSrcObject, setTextContent, setValueForAttribute, setValueForKnownAttribute, setValueForNamespacedAttribute, setValueForStyles, trapClickOnNonInteractiveElement, and 3 more.
What calls setProp()?
setProp() is called by 2 function(s): setInitialProperties, updateProperties.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free