react-native-interaction-provider icon indicating copy to clipboard operation
react-native-interaction-provider copied to clipboard

onInactive gets triggered when view is not on focus

Open nHiRanZ opened this issue 7 years ago • 3 comments

I have implemented the library in several of my views. All of them has a timeout of 10 seconds. When I navigate from View A to View B, the onInactive method of View A still seems to be active and when you travel back (Ex: use pop from navigator), the contents of the method onInactive gets triggered.

How to avoid this?

nHiRanZ avatar Jun 18 '18 12:06 nHiRanZ

Great observation @nHiRanZ - most navigators will still keep the screens in the back stack active when navigating forward.

Off the top of my head, I'm not sure what a great solution would be without a deeper dive into this issue.

What navigator are you using? We'd need some way to "suspend" while not on the active navigation screen, and I'm not sure if we can do that w/o coupling ourselves to the navigator

atticoos avatar Jun 18 '18 14:06 atticoos

Hi @ajwhite, I'm currently using the NavigatorIOS. Yes was thinking the same, or can we try using the same PanHandler instance throughout using a Worker or something like that?

nHiRanZ avatar Jun 19 '18 04:06 nHiRanZ

React's context is probably more appropriate than a Worker for making one thing available to many descendant components -- but either way, I'm not quite sure what you were thinking there. Can you expand on that? What do you have in mind if we shared a single PanHandler instance?

atticoos avatar Jun 19 '18 13:06 atticoos