Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
I want to add progress bar to switch from one screen to another

I am working on a react app. It has simple auth features. The problem is that after a user sign's up, they are forced to wait 6-9 seconds before the landing page loads.

For that reason, I want to add a progress bar as a popup after the user clicks on the SIGN-UP button to notify the user that the page is loading.

 const handlePress = () => {
if (!firstName) {
  Alert.alert("First Name is required");
} else if (!phone) {
  Alert.alert("Phone Number is required.");
} else if (!email) {
  Alert.alert("Email Field is required.");
} else if (!password) {
  Alert.alert("Password Field is required.");
} else {
  registration(email, password, phone, firstName);
  navigation.navigate("Welcome");
  emptyState();
}
  };

<TouchableOpacity style={styles.button} onPress={handlePress}>
      <Text style={{ fontWeight: "bold", color: "#fff", fontSize: 18 }}>
        {" "}
        Sign Up
      </Text>
    </TouchableOpacity>

Someone Help. Relatively new to react and JS.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If you want a progress bar, then registration function will need some modification. It will need an additional parameter onProgress. You will also need keep track of the percentage of completion and update this percentage whenever a milestone is reached:

function registration(email, password, phone, firstName, onProgress){
  let progress = 0;
  const updateProgress = newVal=>{
    progress+=newVal;
    onProgress(progress)
  }
  // when a milestone is reached call updateProgress e.g

  // connected to auth service
  updateProgress(0.2);
  // verified user email doesnt exist
  updateProgress(0.1)
  // createdNewUser
  updateProgress(0.7)
  */
}

Now you want to create a progress variable and choose your progress bar component

import * as Progress from 'react-native-progress';

export default function App({navigation}){
  const [ progress, setProgress ] = useState(0);
  const [ isLoading, setIsLoading ] = useState(false);
  const handlePress = () => {
    if (!firstName) {
      Alert.alert("First Name is required");
    } else if (!phone) {
      Alert.alert("Phone Number is required.");
    } else if (!email) {
      Alert.alert("Email Field is required.");
    } else if (!password) {
      Alert.alert("Password Field is required.");
    } else {
      setIsLoading(true);
      registration(email, password, phone, firstName, setProgress).
        then(()=>{
          setIsLoading(false)
        })
      navigation.navigate("Welcome");
      emptyState();
    }
  };

  return(
    <TouchableOpacity style={styles.button} onPress={handlePress}>
      <Text style={{ fontWeight: "bold", color: "#fff", fontSize: 18 }}>
        {" "}
        Sign Up
      </Text>
      {isLoading && <Progress.Bar progress={progress} />}
    </TouchableOpacity>
  )

Try it out here

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda