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

196
Vistas
I keep getting Expected "`onClick` listener to be a function, instead got a value of `object` type." error and i dont know how to fix it
import React from 'react';
import useState from './App';
import username from './App';
import setUsername from './App';
import setAppState from './App';

function LoginPage(props) {

 const onClick = () => {
    props.onLogin(setUsername);

  }

  return (
    <div className="chat-login-page-container">
     <div className="chat-login-page-controls-container">
       <h4>Set your username</h4>
        <input type="text" 
               placeholder="Username"
               value={props.username} 
               username={username}
               setUsername={username}
           
               onChange={props.onChange} />
           
        <button type="button" disabled={username.length === 0} onClick='onClick'>Log 
 in</button>
      </div>
    </div>
  );
}

export default LoginPage;

I keep trying to fix the code with diffrent variables and trying to make it not a value and it just dosnt work. Im at a loss and dont know what to do.

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

0

  1. First, you should use object destructuring for props

    const {username, onChange, onLogin} = props;

  2. In component "button", the property "onClick" expects a function. With your code onClick='onClick', the property is getting a string and not a function. I'm not sure what the onClick function should do, but it should look somehow like this:

<button type="button" disabled={username.length === 0} onClick={()=>{onLogin(setUsername}}>Log in</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