MCPcopy Index your code
hub / github.com/adobe/react-spectrum / Test

Function Test

packages/react-stately/test/utils/useControlledState.test.tsx:314–336  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

312
313 const AsyncChild = React.lazy(() => new Promise(() => {}));
314 function Test(props) {
315 let [value, setValue] = useState(1);
316 let [showChild, setShowChild] = useState(false);
317
318 return (
319 <>
320 <TransitionButton
321 onClick={() => {
322 setValue(3);
323 setShowChild(true);
324 }}
325 />
326 <Child
327 value={value}
328 onChange={v => {
329 setValue(v);
330 props.onChange(v);
331 }}
332 />
333 {showChild && <AsyncChild />}
334 </>
335 );
336 }
337
338 function Child(props) {
339 let [value, setValue] = useControlledState(props.value, props.defaultValue, props.onChange);

Callers

nothing calls this directly

Calls 2

useControlledStateFunction · 0.90
setValueFunction · 0.50

Tested by

no test coverage detected