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

Function useReducedMotion

packages/@react-spectrum/ai/src/loader/react.tsx:398–414  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

396}
397
398function useReducedMotion() {
399 const [isReducedMotion, setReducedMotion] = React.useState(false);
400 React.useEffect(() => {
401 if (typeof window === 'undefined') {
402 return;
403 }
404 let mq = window.matchMedia('(prefers-reduced-motion: reduce)');
405 let update = () => {
406 setReducedMotion(mq.matches);
407 };
408
409 update();
410 mq.addEventListener('change', update);
411 return () => mq.removeEventListener('change', update);
412 }, []);
413 return isReducedMotion;
414}

Callers 2

AnimatedTabsFunction · 0.90
PixelLoaderFunction · 0.85

Calls 3

addEventListenerMethod · 0.80
removeEventListenerMethod · 0.80
updateFunction · 0.70

Tested by

no test coverage detected