MCPcopy Index your code
hub / github.com/react/react / hydrateTextarea

Function hydrateTextarea

packages/react-dom-bindings/src/client/ReactDOMTextarea.js:150–173  ·  view source on GitHub ↗
(
  element: Element,
  value: ?string,
  defaultValue: ?string,
)

Source from the content-addressed store, hash-verified

148}
149
150export function hydrateTextarea(
151 element: Element,
152 value: ?string,
153 defaultValue: ?string,
154): void {
155 const node: HTMLTextAreaElement = (element: any);
156 let initialValue = value;
157 if (initialValue == null) {
158 if (defaultValue == null) {
159 defaultValue = '';
160 }
161 initialValue = defaultValue;
162 }
163 // Track the value that we last observed which is the hydrated value so
164 // that any change event that fires will trigger onChange on the actual
165 // current value.
166 const stringValue = toString(getToStringValue(initialValue));
167 const changed = trackHydrated((node: any), stringValue, false);
168 if (changed) {
169 // If the current value is different, that suggests that the user
170 // changed it before hydration. Queue a replay of the change event.
171 queueChangeEvent(node);
172 }
173}
174
175export function restoreControlledTextareaState(
176 element: Element,

Callers 1

commitHydratedInstanceFunction · 0.90

Calls 4

toStringFunction · 0.90
getToStringValueFunction · 0.90
trackHydratedFunction · 0.90
queueChangeEventFunction · 0.90

Tested by

no test coverage detected