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

520
Views
MUI - ¿Qué es newValue en la función handleChange?

Tengo este código de ejemplo de MUI Tabs ( https://mui.com/material-ui/react-tabs/#BasicTabs.tsx ). El código completo está abajo.

Mi pregunta es, ¿cuál es el newValue en este código? ¿Qué valor está leyendo y de dónde vino? Lanza un error sin event , por lo que parece que está vinculado, pero no puedo entender completamente esta parte.

 const handleChange = (event: React.SyntheticEvent, newValue: number) => { setValue(newValue); };

CÓDIGO COMPLETO

 import * as React from 'react'; import Tabs from '@mui/material/Tabs'; import Tab from '@mui/material/Tab'; import Typography from '@mui/material/Typography'; import Box from '@mui/material/Box'; interface TabPanelProps { children?: React.ReactNode; index: number; value: number; } function TabPanel(props: TabPanelProps) { const { children, value, index, ...other } = props; return ( <div role="tabpanel" hidden={value !== index} id={`simple-tabpanel-${index}`} aria-labelledby={`simple-tab-${index}`} {...other} > {value === index && ( <Box sx={{ p: 3 }}> <Typography>{children}</Typography> </Box> )} </div> ); } function a11yProps(index: number) { return { id: `simple-tab-${index}`, 'aria-controls': `simple-tabpanel-${index}`, }; } export default function BasicTabs() { const [value, setValue] = React.useState(0); const handleChange = (event: React.SyntheticEvent, newValue: number) => { setValue(newValue); }; return ( <Box sx={{ width: '100%' }}> <Box sx={{ borderBottom: 1, borderColor: 'divider' }}> <Tabs value={value} onChange={handleChange} aria-label="basic tabs example"> <Tab label="Item One" {...a11yProps(0)} /> <Tab label="Item Two" {...a11yProps(1)} /> <Tab label="Item Three" {...a11yProps(2)} /> </Tabs> </Box> <TabPanel value={value} index={0}> Item One </TabPanel> <TabPanel value={value} index={1}> Item Two </TabPanel> <TabPanel value={value} index={2}> Item Three </TabPanel> </Box> ); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Básicamente, el newValue está relacionado con el índice de pestañas.

Entonces, cuando el usuario cambia una pestaña, el código MUI maneja internamente la llamada al evento onChange pasando el evento en sí y el valor nuevo (con el índice de la pestaña presionado). Y con él, MUI identifica en qué pestaña ha hecho clic el usuario y lo cambia para que tenga efecto en la pantalla.

Puedes consultar la definición aquí .

about 4 years ago · Juan Pablo Isaza 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!