Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Button to reload the screen when the WiFi is off

$
0
0

I have a screen that I verify if the WiFi is connected. If the WiFi is off I show in the screen a message and a button Try Again but I would like to click in this button and refresh the screen.

WiFiError Component

import React, { useCallback } from 'react';import { useNavigation } from '@react-navigation/native';import Title from '../Title';import Description from '../Description';import { View, Button, Text } from './styles';interface IWifiErrorProps {  text: string;  navigateTo: string;}const WifiError: React.FC<IWifiErrorProps> = ({ text, navigateTo  }) => {  const navigation = useNavigation();  const handleRefreshTheScreen = useCallback((navigateTo) => {    navigation.navigate(navigateTo);  }, [navigation]);  return (<View><Title title='Ocorreu um erro.' /><Description description={`Não foi possível se conectar ao banco de ${text}.`} /><Button onPress={() => handleRefreshTheScreen(navigateTo)}><Text>TENTAR NOVAMENTE</Text></Button></View>  );}export default WifiError;

When I turn off the WiFi at Dashboard and I navigate to "Ações" appear this as a warning "Possible Unhandled Promise Rejection".


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>