INNER CODE UNIT · TypeScript

onChange

hoaphantn7604/react-native-element-dropdown · src/useDeviceOrientation.ts:20

    const onChange = ({ screen }: { screen: ScaledSize }) => {
      setOrientation({
        portrait: isOrientationPortrait(screen),
        landscape: isOrientationLandscape(screen),
      });
    };

    const subscription = Dimensions.addEventListener('change', onChange);

    return () => {
      if (typeof subscription?.remove === 'function') {
        subscription.remove();
      }
    };
  }, []);

  return orientation.portrait ? 'PORTRAIT' : 'LANDSCAPE';
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…