MCPcopy
hub / github.com/adobe/react-spectrum / setProps

Method setProps

packages/react-aria/src/collections/Document.ts:337–377  ·  view source on GitHub ↗
(
    obj: {[key: string]: any},
    ref: ForwardedRef<E>,
    CollectionNodeClass: CollectionNodeClass<any>,
    rendered?: ReactNode,
    render?: (node: Node<T>) => ReactElement
  )

Source from the content-addressed store, hash-verified

335 }
336
337 setProps<E extends Element>(
338 obj: {[key: string]: any},
339 ref: ForwardedRef<E>,
340 CollectionNodeClass: CollectionNodeClass<any>,
341 rendered?: ReactNode,
342 render?: (node: Node<T>) => ReactElement
343 ): void {
344 let node;
345 let {value, textValue, id, ...props} = obj;
346 if (this.node == null) {
347 node = new CollectionNodeClass(id ?? `react-aria-${++this.ownerDocument.nodeId}`);
348 this.node = node;
349 } else {
350 node = this.getMutableNode();
351 }
352
353 props.ref = ref;
354 node.props = props;
355 node.rendered = rendered;
356 node.render = render;
357 node.value = value;
358 if (obj['aria-label']) {
359 node['aria-label'] = obj['aria-label'];
360 }
361 node.textValue =
362 textValue ||
363 (typeof props.children === 'string' ? props.children : '') ||
364 obj['aria-label'] ||
365 '';
366 if (id != null && id !== node.key) {
367 throw new Error('Cannot change the id of an item');
368 }
369
370 if (props.colSpan != null) {
371 node.colSpan = props.colSpan;
372 }
373
374 if (this.isConnected) {
375 this.ownerDocument.queueUpdate();
376 }
377 }
378
379 get style(): CSSProperties {
380 // React sets display: none to hide elements during Suspense.

Callers

nothing calls this directly

Calls 2

getMutableNodeMethod · 0.95
queueUpdateMethod · 0.80

Tested by

no test coverage detected