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

167
Vistas
Change column header name dynamically in React Table

I am using React Table in my dashboard project. I want to change the React Table column header name on every tab click. I am passing the name state as props in React table, but the Header text is not changing as per the props. Is this possible to change Column header inside it ?

Below is the code of react table component in which the tabName is the state that i am passing as props, which is not changing.

const BreakdownTable = ({ tabName }) => {
  // console.log(tabName);
  const data = React.useMemo(
    () => [
      {
        col1: "com.gumlet.limited-videoPlay",
        col2: "100",
        col3: "1.3k",
      },
    ],
    []
  );

  const columns = React.useMemo(
    () => [
      {
        Header: tabName,
        accessor: "col1",
      },
      {
        Header: "Unique Views",
        accessor: "col2",
      },
      {
        Header: "Total Views",
        accessor: "col3",
      },
    ],
    []
  );

  const {
    getTableProps,
    getTableBodyProps,
    headerGroups,
    // rows,
    prepareRow,
    page,
    canPreviousPage,
    canNextPage,
    pageOptions,
    // pageCount,
    gotoPage,
    nextPage,
    // previousPage,
    setPageSize,
    pageSize,
    state,
    setGlobalFilter,
  } = useTable(
    {
      columns,
      data,
      initialState: { pageSize: 15 },
    },
    useGlobalFilter,
    useSortBy,
    usePagination
  );

  const { globalFilter } = state;

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

0

can you try making column like this, a simple plain javascript array? This will help to determine if the issue is because of useMemo function.

const columns = [
  {
    Header: tabName,
    accessor: "col1",
  },
  {
    Header: "Unique Views",
    accessor: "col2",
  },
  {
    Header: "Total Views",
    accessor: "col3",
  },
]
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