Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'd like to use the shake gesture with React Native. Its currently used for the debug menu and i'm not sure how to override it. Does anyone know if this is possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
242 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can disable developer mode and then provide your own shake handler.

https://github.com/facebook/react-native/issues/1054

You can either change the value [of RCT_DEV] in RCTDefines.h, or in the build settings for the React lib project, search for "Preprocessor Macros" and add RCT_DEV=0 to the section where DEBUG=1 is currently defined.

I think you would then have to implement an Obj-C extension that handles the shake gesture; AFAIK there's no way to do this purely in JavaScript. You may find the code for the Dev Menu a useful guide for this:

https://github.com/facebook/react-native/blob/98263c4f8f6365a8c0c25e5f509928b89d8f1c0c/React/Base/RCTDevMenu.m


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...