addOrientationListener calls listener function infinitely
See original GitHub issueI have the following code:
componentWillMount() {
Orientation.addOrientationListener(this.orientationDidChange)
}
orientationDidChange = orientation => {
console.log(orientation)
}
This is what I end up seeing in the debugger:
Right now this is happening on Android and I have no yet tested it on iOS. Not sure why this is happening. Any help would be much appreciated!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Is there any other way to implement a "listening" function ...
I've written the answer to this question as an aside in another answer. Normally I'd close this question as a duplicate and point...
Read more >A react-native module that can listen on orientation changing ...
addOrientationListener (function(orientation)). When UI orientation changed, callback function will be called. But if lockToXXX is called , callback function ...
Read more >react-native-orientation-locker
A react-native module that can listen on orientation changing of device, get current orientation, lock to preferred orientation.
Read more >Solved: addEventListener function calling multiple times
The problem I'm facing is the function is getting called multiple times and thus the collect tags for GA is getting triggered many...
Read more >Untitled
A rotation by 180° is called point reflection . rotate(a). ... Wheel spinning animation and any other functionality that needs to be spin...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @pouyaemami, one more thing maybe you would like to use
addDeviceOrientationListener
insteadaddOrientationListener (loop)
this method only run one time, I’m using it and works perfectly.@skantus thanks for the advice! It’s working much better now 😃