Created
September 17, 2018 15:29
-
-
Save janhesters/8807177d07b95fe3845b89d921134266 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... Other imports. Only import 'orientation' in the following line, if you are using TypeScript | |
import Orientation, { orientation } from 'react-native-orientation'; | |
export default class App extends Component<Props> { | |
componentDidMount = () => { | |
Orientation.lockToPortrait(); | |
Orientation.addOrientationListener(this.orientationDidChange); | |
}; | |
componentWillUnmount = () => { | |
Orientation.removeOrientationListener(this.orientationDidChange); | |
}; | |
// Again the type declaration 'orientation' is only for TypeScript | |
orientationDidChange = (orientation: orientation) => { | |
console.log(orientation); | |
}; | |
render() { | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment