You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Much like how useWindowDimensions is the prefered over Dimensions, AccessibilityInfo would benefit from hook versions of the properties it exposes.
All of the hooks would be fairly similar to the methodology used by useWindowDimensions. For example:
functionuseScreenReaderEnabled(){// Starting with state being `false` isn't ideal.// It would be better to have the correct inital state, but unfortunately, `AccessibilityInfo.isScreenReaderEnabled` is asyncronous// Possibly something could be implemented at the native level?const[screenReaderEnabled,setScreenReaderEnabled]=useState(false);useEffect(()=>{constsubscription=AccessibilityInfo.addEventListener("screenReaderChanged",(e)=>{setScreenReaderEnabled(e);});returnsubscription.remove;},[]);returnscreenReaderEnabled;}
Equivalent methods could be offered for boldTextEnabled, grayscaleEnabled, invertColorsEnabled, reduceMotionEnabled, and reduceTransparencyEnabled.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Much like how
useWindowDimensions
is the prefered overDimensions
,AccessibilityInfo
would benefit from hook versions of the properties it exposes.All of the hooks would be fairly similar to the methodology used by
useWindowDimensions
. For example:Equivalent methods could be offered for
boldTextEnabled
,grayscaleEnabled
,invertColorsEnabled
,reduceMotionEnabled
, andreduceTransparencyEnabled
.Beta Was this translation helpful? Give feedback.
All reactions