title: How can i redirect to other screens from App.js?
body: <p>I am trying to redirect to another screen when a notification is received in App.js. I am using useNavigation() but it is not working.</p>
  <p>Is there a way to redirect to another screen or use the notifications in another way?</p>
  <pre><code>export default function App() {
    function UserScreen() {  
      const navigation = useRef(useNavigation());  
      navigation.navigate('Chat');
    }
  
  
    useEffect(() =&gt; {
      const backgroundSubscription = Notifications.addNotificationResponseReceivedListener(
        (response) =&gt; {
          switch (response.request?.content.data.type) {
            case 'chat':
              return UserScreen()
            default:
              return console.log('Entro al default')
          }
        }
      );
  
      const foregroundSubscription = Notifications.addNotificationReceivedListener(
        (notification) =&gt; {
          switch (notification.request?.content.data.type) {
            case 'chat':
              return UserScreen()
            default:
              return console.log('Entro al default')
          }
        }
      );
  
      return () =&gt; {
        backgroundSubscription.remove();
        foregroundSubscription.remove();
      };
    }, []);
  
    return (
      &lt;Provider store={store}&gt;
        &lt;SparkitNavigator /&gt;
      &lt;/Provider&gt;
  
    );
  }
  </code></pre>