Get ionic search text

Hello.

I searching how to get the IonSearchbar input text when enter is pressed:


class Busqueda extends Component{

Buscar = () =>{

}
 render(){
  
  return(<IonSearchbar onIonInput={this.Buscar}></IonSearchbar>);
     }
};

What can I implement? thanks in advance.

Try

Buscar = console.log

And see whats happening

Probably u need to add argument to Buscar

So: Buscar= (event)=> { etc}

Grab the event argument that is passed and use e.target.value:

<IonInput type="text" value={username} onIonInput={(e: any) => setUsername(e.target.value)} />