Treat Checkbox with error or success message

Asked

Viewed 57 times

0

I treated it differently. Following a tutorial, I separated the checkbox with a function and where it renders only the status. It was like this:

        this.setState({
            checked: !this.state.checked
        })
        alert('agora está ' + !this.state.checked)
    } ```


<View style={styles.bottomContainer}>

                        <Text style={[styles.bottomContainerText, { color: themes[theme].auxiliaryText }]}>
                            <CheckBox
                                value={this.state.checked}
                                onValueChange={() => this.checkBoxTest()}

                            />
                            {'Li e concordo com os Termos de uso*'}

                        </Text>

                        <Text style={[styles.bottomContainerTextBold, { color: themes[theme].auxiliaryText }]}>
                            {'* Concordo que os dados pessoais fornecidos acima serão utilizados para envio de conteúdo informativo, analítico e publicitário e para contato por parceiros DVinvest, nos termos da Lei Geral de Proteção de Dados.'}
                        </Text>

                    </View>


Agora ele retorna um alert com o status. True = marcado e false = desmarcado. Preciso tratar ele para: quando for true eu tenho a mensagem OK e false eu mando um alert pra ele marcar.
  • Code does not have a minimal example, did not understand the part of the error or warning message (which in my view is much better, error is always problematic) and which is your doubt?

  • I have a box to be marked by the user which by default comes as true (already checked). I need when he clears this box, that he has an error message that this box necessarily needs to be messed up for him to follow.

  • in a few code would be: {!this.state.checked && 'Mensagem de problema'} This shows a warning message!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.