1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/app-mobile/utils/hooks/useReduceMotionEnabled.ts

20 lines
602 B
TypeScript

import useAsyncEffect from '@joplin/lib/hooks/useAsyncEffect';
import { useEffect, useState } from 'react';
import { AccessibilityInfo } from 'react-native';
const useReduceMotionEnabled = () => {
const [reduceMotionEnabled, setReduceMotionEnabled] = useState(false);
useEffect(() => {
AccessibilityInfo.addEventListener('reduceMotionChanged', (enabled) => {
setReduceMotionEnabled(enabled);
});
}, []);
useAsyncEffect(async () => {
setReduceMotionEnabled(await AccessibilityInfo.isReduceMotionEnabled());
}, []);
return reduceMotionEnabled;
};
export default useReduceMotionEnabled;