How do I use hook navigation in interceptor response?

I am having big troubles using useNavigation() in an interceptor response.

First of all, i had to created a new file where i put my function with the navigation.

import React, {useEffect, useState} from 'react';
import {useNavigation, CommonActions} from '@react-navigation/native';

export const NavigateToLogin = () => {
console.log('ENTERS THE FUNCTION ------------');
const navigation =  useNavigation();

and then i imported it where i have my interceptor response

import {NavigateToLogin} from './navigateError';

and finally use it.
interceptor response

case 403:
          //Alert.alert('Error 403', 'Servidor bloqueado'); 
          console.warn('Error 403, Servidor bloqueado');

The problem is that i got a invalid hook errors. I dont know how to deal with this issue.

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app

Source: React Router Questions