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

211
Vistas
'setName' is not defined in functional component

I want to get input value in functional component with hooks. Wrote the code based on the React doc but I faced with this error : What is the problem?

 Line 39:3:     Unexpected use of 'name'   no-restricted-globals
  Line 39:10:    'setName' is not defined   no-undef
  Line 40:3:     'phone' is not defined     no-undef
  Line 40:11:    'setPhone' is not defined  no-undef
  Line 42:16:    Unexpected use of 'name'   no-restricted-globals
  Line 42:23:    'phone' is not defined     no-undef
  Line 127:55:   'setName' is not defined   no-undef
  

This is my code :

import React , {useState} from 'react'
const NewCustomer = () => {
 [name , setName] = useState('');
 [phone , setPhone] = useState('');
 const addCustomer= ()=>{
   console.log(name , phone);
 }
    return (
                <CForm action="submit" >
                <CFormGroup row>
                  <CCol md="3">
                    <CLabel >Name  </CLabel>
                  </CCol>
                  <CCol xs="12" md="9">
                    <CInput type="text" onChange={e=> setName(e.target.value)}  autoComplete="" />
                    
                  </CCol>
                </CFormGroup>
                <CFormGroup row>
                  <CCol md="3">
                    <CLabel > Phone number</CLabel>
                  </CCol>
                  <CCol xs="12" md="9">
                  <CInput type="number" onChange={e=> setPhone(e.target.value)} autoComplete="current-tel"/>
                  
                  </CCol>
                </CFormGroup>
 <CButton type="submit" onClick={()=> addCustomer()}  > Insert </CButton>
                  
                   
</CForm>
)}
about 4 years ago · Juan Pablo Isaza
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