Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49086

Pass a hook and a function to a function

$
0
0

Hello everyone.

Given the main component called Registro, which has 2 components in IonContent: RegistroNuevaCuenta and IonAlert

What I need is to pass the hook showAlert to RegistroNuevaCuenta So that this is the one who shows the IonAlert. Is this possible?

const Registro: React.FC = () => {
  const [showAlert, setShowAlert] = useState(false);

  return (
    <IonPage>
      <IonHeader>
      <IonToolbar>
        <IonGrid>
          <IonRow>
          <IonCol size="1"><a href={"/home"}><IonIcon icon={arrowBack}  id="flecha-volver">  </IonIcon></a></IonCol>
          <IonCol id="columna2" ><strong id="texto-pagina">Registro</strong></IonCol>
          </IonRow>
        </IonGrid>
      </IonToolbar>
      </IonHeader>
      <IonContent fullscreen>
        <RegistroNuevaCuenta></RegistroNuevaCuenta>
        
        <IonAlert
          isOpen={showAlert}
          onDidDismiss={() => setShowAlert(false)}
          cssClass='my-custom-class'
          header={'Alert'}
          subHeader={'Subtitle'}
          message={'This is an alert message.'}
          buttons={['OK']}
        />
      </IonContent>
    </IonPage>
  );
};

const RegistroNuevaCuenta = () => {
const [tipo, setCount] = useState(0)
const [user, setUser] = useState(0)
const [email, setEmail] = useState(0)
const [password, setPassword] = useState(0)

const [codigo, setCodigo] = useState(0)
const [codigo_agregado, setCodigo_agregado] = useState(1)

/*
more code that doesn’t matter
*/
}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49086

Trending Articles