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

186
Vistas
ReactJs - Ant design Tabs Card does not render content

My components used ReactJs Framework that built with Ant Design UI. My stucking is the rendering on tabs content.

I try to nest the LoginForm component to TabsCard component.

Note: the LoginForm component can successful independently rendered without nesting case.

Component rendered on image I attachted:

enter image description here

Here is my code:
TabsCard.js

import React, { useState } from 'react';
import { Card } from 'antd';
import LoginForm from '../LoginForm/index.js';

function TabsCard() {
  const tabList = [
    {
      key: 'tab1',
      tab: 'Sign in'
    },
    {
      key: 'tab2',
      tab: 'Sign up'
    }
  ];

  const contentList = {
    tab1: <LoginForm />,
    tab2: <p>signup</p>,
  };

  const [activeTab, setActiveTab] = useState('tab1');
  const handleTabChange = key => {
    setActiveTab(key);
  };

  return (
    <Card
      style={{ width: '400' }}
      tabList={tabList}
      activeTabKey={activeTab}
      onTabChange={key => {
        handleTabChange(key);
      }}
    >
      {contentList[setActiveTab]}
    </Card>
  );
}
export default TabsCard;

Thank you for your support!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Change from contentList[setActiveTab] to contentList[activeTab]

Example of full code

import React, { useState } from 'react';
import { Card } from 'antd';
import 'antd/dist/antd.css';

function TabsCard() {
  const tabList = [
    {
      key: 'tab1',
      tab: 'Sign in'
    },
    {
      key: 'tab2',
      tab: 'Sign up'
    }
  ];

  const contentList = {
    tab1: <div>Login form</div>,
    tab2: <p>signup</p>,
  };

  const [activeTab, setActiveTab] = useState('tab1');
  const handleTabChange = key => {
    setActiveTab(key);
  };

  return (
    <Card
      style={{ width: '400' }}
      tabList={tabList}
      activeTabKey={activeTab}
      onTabChange={key => {
        handleTabChange(key);
      }}
    >
      {contentList[activeTab]}
    </Card>
  );
}
export default TabsCard;

I hope I've helped you

Have a nice day!

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