mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-27 10:32:58 +02:00
20 lines
602 B
TypeScript
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;
|