MCPcopy Create free account
hub / github.com/adobe/react-spectrum / setProps

Method setProps

packages/react-aria/src/collections/Document.ts:339–379  ·  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

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