Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
'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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!