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

156
Visualizações
Modal not showing when setting visibility in UseEffect call

Hi so I am trying to conditionally set the visibility of a modal (react-native-modal) in the useEffect function of one of my components. The issue is the modal sometimes doesn't show even though the visibility is set to true. Also when this happens it prevents me from interacting with the page below it pretty much breaking the app and causing the user to have to clear it before proceeding.

Here is how i render my modal in the return(the view is just a placeholder):

<Modal
    isVisible={guidanceVisible}
    style={styles.guidanceModalContainer}
    onBackdropPress={() => null}
    backdropOpacity={.75}
  >
    <View style={{
      width: '100%',
      height: '100%',
      backgroundColor: 'green'
    }}/>
  </Modal>

Initialize State: const [guidanceVisible, setGuidanceVisible] = useState(false);

setGuidance in useEffect:

useEffect(() => {
if(myPosts.length > 1){
  // setTimeout(() => {
    setGuidanceVisible(true)
  // }, 500)
}}, []);

As you can see I have already tried using a setTimeout but then I run into a different error. If a user interacts with the page while the timeout is waiting to be called then the same issue as before with the page being uninteractable happens again. Please let me know if you have any ideas or spot any mistakes. Thanks ahead of time!

about 4 years ago · Juan Pablo Isaza
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