Open
Description
Initial values returned by this hook can be incorrect based od how was app started and when hook mounted.
Example:
App is started in portrait
, then orientation is chaged to landscape
and after that this hook is mounted. It will show that device is in landscape.
Not sure if this is by design or it's a bug.
My current solution looks like this:
function getDimensions() {
return Dimensions.get("screen");
}
...
function useMyDeviceOrientation() {
...
const [orientation, setOrientation] = useState({
portrait: isOrientationPortrait(getDimensions()),
landscape: isOrientationLandscape(getDimensions()),
});
...
}
Metadata
Metadata
Assignees
Labels
No labels