jkomyno/react-native-user-inactivity

How to reset timer from Component

NJJ2 opened this issue · 7 comments

NJJ2 commented

Hi,

Thanks for the library. I use react-navigation to move between screens. while navigate to another screen I want to disable the timer and when i come back to previous screen I want to reset the timer. is there any props to handle these two options. Please let me know.

@jkomyno Any idea how I could do this with the current package? I interact with hardware, sometimes the user does not touch the screen, but they are interacting with the device via barcode scanning.

Hi, offering the possibility to stop and start the timer seems like a nice feature to have. I'm open to PRs, otherwise I could probably take a look at the beginning of May.

Hi,

Thanks for the library. I use react-navigation to move between screens. while navigate to another screen I want to disable the timer and when i come back to previous screen I want to reset the timer. is there any props to handle these two options. Please let me know.

i also facing same issue please update me if possible this to manage with multiple screen

hi
i have successfully manage this concept for whole app if you are inactive in any screen for specific time you can manage inactivity by wrapping up like below code

<UserInactivity
                style={cs.normalPage}
                timeForInactivity={300000}
                checkInterval={1000}
                onAction={this.onAction}> set here you navigator or first component with used by you</UserInactivity>  end tag here

feel free to ask any query you have
Thanks

Closing for inactivity

I created a PR adding the disabled prop. It can be used as follows:

import {useIsFocused} from '@react-navigation/native';

...

  const isFocused = useIsFocused();

  return (
...
      <UserInactivity
        isActive={active}
        timeForInactivity={timer}
        onAction={isActive => setActive(isActive)}
        disabled={!isFocused}
      >

@jkomyno, please take a look at those 2 PRs. Having the ability to disable this in certain scenarios is important.