-2
I have a button that changes the visibility of my modal and puts as true, after that the intention was to show the modal on screen as if it was an Alert.
const Cadastro = () => {
let history = useHistory();
const [ isModalVisibel, setIsModalVisible ] = useState(false);
function login({ username, user, password, selectOption, selectOptionMonth, selectOptionYear }) {
const data_aniversario =
selectOption + "/" + selectOptionMonth + "/" + selectOptionYear;
const dados = {
nome_pessoa: username,
data_nascimento: data_aniversario,
email: user,
senha: password,
};
console.log(dados.nome_pessoa);
return(
<div>
{isModalVisibel
? <Modal onClose={() => setIsModalVisible(false)}>
<h1>Janela de informações</h1>
</Modal>
: null
}
</div>
)
Below I’ll leave the way I’m using the button. NOTE: The button is inside a form
<button onClick={() => setIsModalVisible(true)} type="submit">Cadastrar</button>