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

175
Vistas
Tabs: `key` is not a prop. Trying to access it will result in `undefined` being returned.?

I am getting this warning

Warning: Tabs: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it 

I am already passing key in my component .don't know where I am doing wrong.

here is my code https://codesandbox.io/s/priceless-edison-g09nz?file=/src/App.js

<Tabs>
      {data.reduce((result, tabItem, tabIndex) => {
        result.push(<Tab {...getTabItemProps(tabItem, tabIndex)} key={tabIndex}/>);
        return result;
      }, [])}
    </Tabs>

Tabs.js

 <>
    <ul className="rc64nav" ref={tabsRef}>
      {tabsVisible.reduce((result, tabItem, tabIndex) => {
        result.push(tabItem);
        return result;
      }, [])}

    </ul>
    <ul>
    <hr/>
    <div>break</div>
      <hr/>
      {tabsHidden.reduce((result, tabItem, tabIndex) => {
        result.push(tabItem);
        return result;
      }, [])}
    </ul>
    </>

Tab.js

import React from "react";

const Tabs = ({ title,hidden }) => {
  return <li className={hidden ? 'hidden':'not-hidden'}>{title}</li>;
};

export default Tabs;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I fixed the error: https://codesandbox.io/s/beautiful-sid-l9753?file=/src/tabs.js.

What I changed: I added a prop called tabKey. In App.js:

const getTabItemProps = (tabItem, tabIndex) => ({
  title: tabItem,
  key: tabIndex,
  tabKey: tabIndex
});

I made tabs.js reference tabKey instead of trying to use key as a prop:

const { tabKey = index } = tabItem.props;
about 4 years ago · Juan Pablo Isaza Denunciar
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