react-native-orientation-locker icon indicating copy to clipboard operation
react-native-orientation-locker copied to clipboard

Module '"react-native-orientation-locker"' has no exported member 'useDeviceOrientationChange'

Open taschik opened this issue 3 years ago • 2 comments

Hi, Thank you so much for building this library. I tried to take advantage of the hooks but when I try to import the hook useDeviceOrientationChange like this:

import Orientation, { useDeviceOrientationChange } from 'react-native-orientation-locker'

I am getting the error Module '"react-native-orientation-locker"' has no exported member 'useDeviceOrientationChange'.

Why would that be?

Thanks so much for supporting :)

taschik avatar Mar 18 '21 22:03 taschik

If you're using the package from npm, the latest release is 1.2.0 from last August, which does not have the hooks. If you look at the README from that version tag, they're not even mentioned: https://github.com/wonday/react-native-orientation-locker/tree/v1.2.0

I haven't tried using this library from the master branch and do not know if it's stable to use that way. I also don't know when they intend to release a new version with the hooks. I would like to use them as well.

lafiosca avatar Apr 02 '21 16:04 lafiosca

In the meantime however, this seems to work for me... although the TypeScript typings are missing:

import ScreenOrientation from 'react-native-orientation-locker/ScreenOrientation';

/* ... */

	const onChangeOrientation = useCallback(
		(orientation: string) => {
			console.log(`device orientation change: ${orientation}`);
		},
		[],
	);

/* ... */

	return (
		<View>
			<ScreenOrientation onDeviceChange={onChangeOrientation} />
			{/* ... */}
		</View>
	);

lafiosca avatar Apr 02 '21 16:04 lafiosca