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

203
Visualizações
REACT- Multiple Tabs don't work, headers and body don't diplayed

I tried to use multiple tabs in react. But it doesn't seem working (please see the picture). I 'm not able to display the header for my Tabs neither the body (from match.json) that should contained a textbox field as input...

import React from "react";
import { Tab, Tabs as TabsComponent, TabList, TabPanel } from "react-tabs";
import "react-tabs/style/react-tabs.css";

const Tabs = ({ data }) => (
  <TabsComponent>
    <TabList>
      {data.map(({ name }, i) => (
        <Tab key={i}>{name}</Tab>
      ))}
    </TabList>
    {data.map(({ name }, i) => (
      <TabPanel key={i}>{name}</TabPanel>
    ))}
  </TabsComponent>
);

export default Tabs;

MenuItemDisplay:

 export default function MenuItemDisplay() {
  const { match } = JsonData;
  ...
        <Tabs data={match.questions[0]} />
      </div>
    </>
  );
}

match.json :

 {
  "match": [
    {
      ...
      "_ids": [
          "questions": [
            {
              "name": "Tell me about yourself ",
              "typeProof": ""
            },
            ...
          ],
        ]
      }
    ]
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The data that you want to send to the Tabs component is the currently matched item's questions array.

const { menuId, itemId } = useParams();
const { match } = JsonData;

const matchData = match.find((el) => el._id_menu === menuId)?._ids ?? [];
const item = matchData.find((el) => el._id === itemId);

Here item is the current menu item being rendered, "Pea Soup", or item "123ml66" for example:

{
  "_id": "123ml66",
  "name": "Pea Soup",
  "description": "Creamy pea soup topped with melted cheese and sourdough croutons.",
  "dishes": [
    {
      "meat": "N/A",
      "vegetables": "pea"
    }
  ],
  "questions": [
    {
      "name": "Tell me about yourself ",
      "typeProof": ""
    },
    {
      "name": "Why our restaurant?",
      "typeProof": ""
    },
    {
      "name": "What hours are you available to work ?",
      "typeProof": "Planning"
    }
  ],
  "invited": [
    {
      "name": "Jose Luis",
      "location": "LA"
    },
    {
      "name": "Smith",
      "location": "New York"
    }
  ],
  "taste": "Good",
  "comments": "3/4",
  "price": "Low",
  "availability": 0,
  "trust": 1
},

Pass item.questions to the Tabs component.

<Tabs data={item.questions} />

...

const Tabs = ({ data }) => (
  <TabsComponent>
    <TabList>
      {data.map(({ name }, i) => (
        <Tab key={name}>Question {i + 1}</Tab>
      ))}
    </TabList>
    {data.map(({ name }) => (
      <TabPanel key={name}>{name}</TabPanel>
    ))}
  </TabsComponent>
);

Edit react-multiple-tabs-dont-work-headers-and-body-dont-diplayed

enter image description here

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