Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28480

React-native-shake not detecting shake

$
0
0

I'm trying to get my android app to detect a shake, so the user can return to a previous screen. I have installed react-native-shake and linked the package. My code is below but i'm not sure why it won't pick up a shake. I'm using an android emulator and shaking it through the menu.

I added the console.log just to check for output but it's not printing.

componentDidMount() {
    RNShake.addEventListener("ShakeEvent", () => {
      //this.props.navigation.navigate("Search")
      console.log("SHAKE DETECTED")
    })
  }

  componentWillUnmount() {
    RNShake.removeEventListener("ShakeEvent")
  }

Viewing all articles
Browse latest Browse all 28480

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>