Julien
Julien

Reputation: 51

How to detect shake event with Expo React-Native?

I would like to know if it's possible to detect shake event with Expo ?

Upvotes: 3

Views: 3798

Answers (1)

Vencovsky
Vencovsky

Reputation: 31635

You can use DeviceMotion and adding a event listener for rotationRate.

rotationRate (object) -- Rotation rates of the device around each of its axes as an object with alpha, beta, gamma keys where alpha is around Z axis, beta for X axis and gamma for Y axis.

With this you can also look in what axis the user is rotating the phone (maybe you want different actions depending on the shake direction).

Upvotes: 4

Related Questions