api – UseEffect cleaning function does not work


Hello I am trying to cancel my API call with Axios if the component is not deployed and although it looks like it has been canceled the error is still displayed:

The response status cannot be updated for an unmounted component. This is a no-op, but indicates a memory leak in your application. To fix this, cancel all subscriptions and asynchronous tasks in% s.% S, a function to clean up useEffect.

I try to do the cleaning as follows:

  useEffect(() => {
    const source = axios.CancelToken.source();

    if(requestLoading){
      async function addNewUser() {
        await api.post('/api/Auth/register', {
          name,
          email,
          password
        },{
          cancelToken: source.token
        }).then(response => {
          const statusCode = response.status
          setRequestLoading(false)
          if (statusCode == 201) {
            navigation.navigate('home')
          }

        }).catch(error => {
          setRequestLoading(false)

          if(axios.isCancel(error)) {
            console.log('Request canceled')
          } else {
            setModalVisible(true)
            setApiMessage(error.response.data.errors)
            setTimeout(() => {
                setModalVisible(false)
            }, 3000)
            Vibration.vibrate(500)
          }
        }) 
      }
      addNewUser()

//FUNÇÃO DE LIMPEZA
      return () => {
        console.log('unmounting')
        setRequestLoading(false)
        source.cancel()
      }
    }
  }, (requestLoading))

If anyone can help me figure out where I'm wrong, thank you for being a new developer with React Native!