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

Function setValue

packages/react-stately/src/select/useSelectState.ts:180–197  ·  view source on GitHub ↗
(value: Key | Key[] | null)

Source from the content-addressed store, hash-verified

178 ? controlledValue[0]
179 : controlledValue;
180 let setValue = (value: Key | Key[] | null) => {
181 if (selectionMode === 'single') {
182 let key = Array.isArray(value) ? (value[0] ?? null) : value;
183 setControlledValue(key);
184 if (key !== displayValue) {
185 props.onSelectionChange?.(key);
186 }
187 } else {
188 let keys: Key[] = [];
189 if (Array.isArray(value)) {
190 keys = value;
191 } else if (value != null) {
192 keys = [value];
193 }
194
195 setControlledValue(keys);
196 }
197 };
198
199 let listState = useListState({
200 ...props,

Callers 15

useSelectStateFunction · 0.70
useIdFunction · 0.50
useValueEffectFunction · 0.50
useTextFieldFunction · 0.50
useHiddenSelectFunction · 0.50
TestComponentFunction · 0.50
TestFunction · 0.50
ChildFunction · 0.50
Slider.test.jsFile · 0.50
Calendar.test.jsFile · 0.50

Calls

no outgoing calls

Tested by 5

TestComponentFunction · 0.40
TestFunction · 0.40
ChildFunction · 0.40
ControlledCalendarFunction · 0.40
ControlledRadioGroupFunction · 0.40