The observingZones won't start again after stopping it

My application is about making timely validation on student attendance.
First, I want to check whether the student is in the right location, I have set a timer by which if student is not in their location for 20s, then the system will notify them. If they are in the right collection, proceed to timely validation:

const timer = BackgroundTimer.setInterval(() => {
    time++;

  if(!notFound){
    RNEP.proximityObserver.stopObservingZones();
    BackgroundTimer.clearInterval(timer);
    dispatch({type: RIGHT_LOCATION});
    startProximityObserver();
  }
  if(time > 20){
    RNEP.proximityObserver.stopObservingZones();
    BackgroundTimer.clearInterval(timer);
    dispatch({type: WRONG_LOCATION});
  }
}, 1000);

The timely validation is to constantly check if the student is in that place or not:

startProximityObserver(){
zone.onEnterAction = () => {
  const timer = BackgroundTimer.setInterval(() => {
    //Wont execute on second call
  }, 1000);
};

zone.onExitAction = () => {
  dispatch({
    type: EXIT_CLASS,
    payload: { inClass: false }
  });
};

RNEP.proximityObserver.startObservingZones([zone]);
}

The startObservingZones does not executed on the second call. Is it because I call the stopObservingZones event or because of the timer? Thank you

Your only call to startProximityObserver is in your timer, so when you stop the timer:

BackgroundTimer.clearInterval(timer);

… then first code snippet will stop executing, and with it, the startProximityObserver.

Instead of relying on repeating timers, maybe consider leaning on the enter/exit events more:

var studentLeftTimer;
zone.onExitAction = () => {
  // schedule a timer to go on in 20 seconds with a notification
  studentLeftTimer = setTimeout(() => { /* notify */ }, 20000);
};
zone.onEnterAction = () => {
  // if the student came back in range of the beacon
  // AND there's an active studentLeftTimer, cancel it
  if (studentLeftTimer) {
    clearTimeout(studentLeftTimer);
    studentLeftTimer = null;
  }
}