Closed Slessi closed 2 years ago
Yes that is expected. Once the prompt is fired you are in the prompt state. If you want activity to automatically close the prompt you can hook into the onAction
event.
@SupremeTechnopriest closing the prompt is easy, but it doesn't stop onIdle
from firing.
E.g. If I want to show a warning prompt, then after prompt times out logout a user, am I expected to call activate
in onAction
?
const { activate } = useIdleTimer({
onPrompt: () => showPrompt(),
onIdle: () => logout(),
onAction: () => {
activate(); // Without this, the prompt will close, but onIdle is still called
closePrompt();
},
});
You can check for isPrompted inside onAction and call activate or reset.
Question
onPrompt
=>onActive
is not called (expected)onIdle
=>onActive
is called (expected)onPrompt
but beforeonIdle
=>onActive
is not called (?)Is scenario 3 expected? I would've thought an action after
onPrompt
would trigger theonActive
event and prevent theonIdle
event from being called.If this is expected, am I meant to call
activate
insideonAction
to get the functionality I am describing?sandbox (look at console): https://codesandbox.io/s/upbeat-banzai-1ibixc?file=/src/App.js
In below,
onActive
log was not triggered despite triggering anonAction
afteronPrompt
.onActive
is only triggered afteronIdle
.