@iterable/react-native-sdk - v2.0.3
    Preparing search index...

    Function useDeviceOrientation

    • Custom hook to get the current device orientation.

      This hook returns the height, width, and a boolean indicating if the device is in portrait mode. It listens to changes in the window dimensions and updates the orientation accordingly.

      Returns IterableDeviceOrientation

      An object containing the height, width, and a boolean isPortrait indicating if the device is in portrait mode.

      const { height, width, isPortrait } = useDeviceOrientation();
      

      The useEffect hook only includes width in its dependency array. This is because the height and width are typically updated together, and including only width prevents unnecessary re-renders.