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

175
Views
el componente secundario pasa accesorios al estado de uso de los padres -> devuelve indefinido (React.js)

Quiero poner los accesorios del componente secundario en el valor de useState del componente principal, pero también viene con undefined. ¿Cómo no puedo quedar indefinido?

Componente hijo

 const FilterSelect = props => {
 const [filterUser, setFilterUser] = useState('all')

 const handleFilterUser = ({ target }) => {
 setFilterUser(target.value)
 }
 useEffect(() => {
 props.propFunction(filterUser)
 }, [filterUser])

 return (
 <Box sx={{ width: 120 }}>
 <FormControl fullWidth>
 <Select
 size="small"
 labelId="user-select-label"
 id="user-select"
 value={filterUser}
 label="filter"
 onChange={handleFilterUser}
 >
 </Select>
 </FormControl>
 </Box>
 )
}

componente principal

 import FilterSelect from './components/FilterSelect'

const UserList = () => {
 const [filterSelectOne, setFilterSelectOne] = useState('all')

 const highFunction = text => {
 setFilterSelectOne(text)
 }

 useEffect(() => {
 highFunction()
 }, [])

 console.log(filterSelectOne) // 'all', undefined

 return (
 <Box sx={{ width: '100%' }}>
 <Paper sx={{ width: '100%', mb: 2 }}>
 <FilterSelect propFunction={highFunction} />
 </Paper>
 </Box>
 )
}

ingrese la descripción de la imagen aquí

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Elimine el efecto de uso donde llama a highFunction sin parámetros en el componente principal

almost 4 years ago · Santiago Trujillo Report
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!