question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addOrientationListener calls listener function infinitely

See original GitHub issue

I have the following code:

  componentWillMount() {
    Orientation.addOrientationListener(this.orientationDidChange)
  }
  orientationDidChange = orientation => {
    console.log(orientation)
  }

This is what I end up seeing in the debugger: Screen Shot 2019-06-08 at 3 38 54 PM

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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
skantuscommented, Jun 13, 2019

Hi @pouyaemami, one more thing maybe you would like to use addDeviceOrientationListener instead addOrientationListener (loop) this method only run one time, I’m using it and works perfectly.

1reaction
pouyaemamicommented, Jun 13, 2019

@skantus thanks for the advice! It’s working much better now 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found