Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
React MUI 4 SelectInput.js:340 TypeError no capturado: no se pueden leer las propiedades de undefined (leyendo 'valor')

Este error ocurre cuando proporciona una matriz vacía como options .

El registro de errores:

 SelectInput.js:340 Uncaught TypeError: Cannot read properties of undefined (reading 'value') at SelectInput.js:340:1 at Array.map (<anonymous>) at SelectInput.js:339:1 at invokePassiveEffectCreate (react-dom.development.js:23487:1) at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1) at invokeGuardedCallback (react-dom.development.js:4056:1) at flushPassiveEffectsImpl (react-dom.development.js:23574:1) at unstable_runWithPriority (scheduler.development.js:468:1) at runWithPriority$1 (react-dom.development.js:11276:1) at flushPassiveEffects (react-dom.development.js:23447:1) at performSyncWorkOnRoot (react-dom.development.js:22269:1) at react-dom.development.js:11327:1 at unstable_runWithPriority (scheduler.development.js:468:1) at runWithPriority$1 (react-dom.development.js:11276:1) at flushSyncCallbackQueueImpl (react-dom.development.js:11322:1) at flushSyncCallbackQueue (react-dom.development.js:11309:1) at flushPassiveEffectsImpl (react-dom.development.js:23620:1) at unstable_runWithPriority (scheduler.development.js:468:1) at runWithPriority$1 (react-dom.development.js:11276:1) at flushPassiveEffects (react-dom.development.js:23447:1) at react-dom.development.js:23324:1 at workLoop (scheduler.development.js:417:1) at flushWork (scheduler.development.js:390:1) at MessagePort.performWorkUntilDeadline (scheduler.development.js:157:1)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

En mi caso, mi componente se veía así. Debes centrarte en la parte de las options solo en el pensamiento.

 <FormControl error={error}> <InputLabel>{label}</InputLabel> <Select value={value} onChange={onChange} label={label} > { options.length && options.map((option, i) => { return (<MenuItem className={classes.menuItem} key={i} value={option}>{option}</MenuItem>) }) } </Select> { error && <FormHelperText>{ helperText }</FormHelperText> } </FormControl>

Cuando cambié mi componente para que se vea así

 <FormControl error={error}> <InputLabel>{label}</InputLabel> <Select value={value} onChange={onChange} label={label} > { // --> Notice below changes options.length > 0 && // --> Changes from `options.length ? ...` to `options.length > 0 && ...` options.map((option, i) => { return (<MenuItem className={classes.menuItem} key={i} value={option}>{option}</MenuItem>) }) } </Select> { error && <FormHelperText>{ helperText }</FormHelperText> } </FormControl>

Y luego no volvió a pasar.

Si desea una explicación más larga , el registro de errores se refería a InputJS:340:1 que se refiere a la siguiente línea

 React.useEffect(function () { if (!foundMatch && !multiple && value !== '') { var values = childrenArray.map(function (child) { return child.props.value; // ---> This line specifically }); console.warn(["Material-UI: You have provided an out-of-range value `".concat(value, "` for the select ").concat(name ? "(name=\"".concat(name, "\") ") : '', "component."), "Consider providing a value that matches one of the available options or ''.", "The available values are ".concat(values.filter(function (x) { return x != null; }).map(function (x) { return "`".concat(x, "`"); }).join(', ') || '""', ".")].join('\n')); } }, [foundMatch, childrenArray, multiple, name, value]);

Digamos simplemente options.length ? ... condicional permite que "cualquier valor" se deslice mientras SelectInput.js esperaba que fuera una matriz de elementos secundarios, pero en lugar de obtener una matriz, obtiene ese "cualquier valor".

Es por eso que cuando child.props.value esperaba un valor transformado, resultó en Cannot read properties of undefined (reading 'value') . Porque el child probablemente ni siquiera tiene definido el valor de los props .

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda