Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
How to achieve "e.target.value" in react native

i wanna access button value in react native, in pure javascript it look like :

const checkingStuff = (e) => console.log(e.target.value)

<button onclick={checkingStuff} > this is the value </button>.

how to achieve the same thing in react native?

edit : please answer in react native, not react js, because

<Button
onPress={checkingStuff}
title='lalala123'/>

give me 'undefined'.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

event handlers give you inherent access to the event through the function. Unless specifically setting state within the DOM, there's no need to do an inline arrow function. You can simply reference the function like so:

const checkingStuff = (e) => { console.log(e.target.value) }

<button onClick={checkingStuff} > Set state and add your {value} like so </button>
about 4 years ago · Juan Pablo Isaza Denunciar

0

I don't know excatly what you try to achieve, however you should access the event directly in the input instead of the button. For TextInput in React Native, the changed text is passed as a single string argument to the callback handler.

You can try this

const [text, onChangeText] = useState("")
const onPress = () => {
   console.log(text)
}

return (
    <>
        <TextInput value={text} onChangeText={onChangeText}>
        <Button onPress={onPress}/>
    </>
)
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can get like this:

const checkingStuff = (e) => console.log(e.target.value)

<button onclick={(e) => checkingStuff(e)} > this is the value </button>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda