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

173
Visualizações
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 Respostas
Responde à pergunta

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 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