android – Recursive methodology is looking many times


    const callAFunction = () => {
      if (AppState.currentState === 'background') {
        function1()
      }
    }

    useEffect(()=>{
AppState.addEventListener('change', callAFunction);
    },[])
    const function1 = () => {
      axios.get('/user_login', {
        params: {
          username: 'john1904',
        }
      })
        .then(operate (response) {
          if (response.knowledge.standing === false) {
            function1()
          }
    
        })
    }

I’m utilizing this above operate recursively. However because the app goes background function1 is looking many times as nonetheless the function1() i’ve already known as. So i would like that function1() name each time because the app goes background. However in Async kind as if function1() then it is not going to name it once more.

So i’m not capable of get how am i able to do that in when app is in background so it is going to examine if this operate is operating then do not run it different smart run it.

Leave a Reply

Your email address will not be published.