updateInput() — react Function Reference
Architecture documentation for the updateInput() function in ReactDOMInput.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac["updateInput()"] ebd36fdb_cc70_52b6_9971_bcace1958602["ReactDOMInput.js"] 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac -->|defined in| ebd36fdb_cc70_52b6_9971_bcace1958602 336b5c16_66c9_7089_05c5_2ec95eb7ed11["updateProperties()"] 336b5c16_66c9_7089_05c5_2ec95eb7ed11 -->|calls| 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac eb91f874_8ee4_2703_d333_d67f28ac1a0b["restoreControlledInputState()"] eb91f874_8ee4_2703_d333_d67f28ac1a0b -->|calls| 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac 14e1dad9_019e_0b6b_45f9_989dc6db3084["toString()"] 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac -->|calls| 14e1dad9_019e_0b6b_45f9_989dc6db3084 7404ee30_0cd4_7886_2806_324f301962c4["getToStringValue()"] 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac -->|calls| 7404ee30_0cd4_7886_2806_324f301962c4 6df08396_fc7c_51c1_8a38_b8ab9badd796["setDefaultValue()"] 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac -->|calls| 6df08396_fc7c_51c1_8a38_b8ab9badd796 style 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/client/ReactDOMInput.js lines 89–204
export function updateInput(
element: Element,
value: ?string,
defaultValue: ?string,
lastDefaultValue: ?string,
checked: ?boolean,
defaultChecked: ?boolean,
type: ?string,
name: ?string,
) {
const node: HTMLInputElement = (element: any);
// Temporarily disconnect the input from any radio buttons.
// Changing the type or name as the same time as changing the checked value
// needs to be atomically applied. We can only ensure that by disconnecting
// the name while do the mutations and then reapply the name after that's done.
node.name = '';
if (
type != null &&
typeof type !== 'function' &&
typeof type !== 'symbol' &&
typeof type !== 'boolean'
) {
if (__DEV__) {
checkAttributeStringCoercion(type, 'type');
}
node.type = type;
} else {
node.removeAttribute('type');
}
if (value != null) {
if (type === 'number') {
if (
// $FlowFixMe[incompatible-type]
(value === 0 && node.value === '') ||
// We explicitly want to coerce to number here if possible.
// eslint-disable-next-line
node.value != (value: any)
) {
node.value = toString(getToStringValue(value));
}
} else if (node.value !== toString(getToStringValue(value))) {
node.value = toString(getToStringValue(value));
}
} else if (type === 'submit' || type === 'reset') {
// Submit/reset inputs need the attribute removed completely to avoid
// blank-text buttons.
node.removeAttribute('value');
}
if (disableInputAttributeSyncing) {
// When not syncing the value attribute, React only assigns a new value
// whenever the defaultValue React prop has changed. When not present,
// React does nothing
if (defaultValue != null) {
setDefaultValue(node, type, getToStringValue(defaultValue));
} else if (lastDefaultValue != null) {
node.removeAttribute('value');
}
} else {
// When syncing the value attribute, the value comes from a cascade of
// properties:
// 1. The value React property
// 2. The defaultValue React property
// 3. Otherwise there should be no change
if (value != null) {
setDefaultValue(node, type, getToStringValue(value));
} else if (defaultValue != null) {
setDefaultValue(node, type, getToStringValue(defaultValue));
} else if (lastDefaultValue != null) {
node.removeAttribute('value');
}
}
if (disableInputAttributeSyncing) {
// When not syncing the checked attribute, the attribute is directly
// controllable from the defaultValue React property. It needs to be
// updated as new props come in.
if (defaultChecked == null) {
Domain
Subdomains
Source
Frequently Asked Questions
What does updateInput() do?
updateInput() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMInput.js.
Where is updateInput() defined?
updateInput() is defined in packages/react-dom-bindings/src/client/ReactDOMInput.js at line 89.
What does updateInput() call?
updateInput() calls 3 function(s): getToStringValue, setDefaultValue, toString.
What calls updateInput()?
updateInput() is called by 2 function(s): restoreControlledInputState, updateProperties.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free