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

272
Visualizações
Passing data on another page by clicking the row: It shows that data is null

I am using MUI-Datatable. And it can already go to the next page, however, no data is showing in History page. How can I fix this?

Passing data to another page:

Here, I can see the data in the console

  const handleRowClick = (rowData, rowMeta) => {
    navigate("/history", rowData[0]);
    console.log(rowData[0], "products");
  };

  const options = {
    filter: true,
    selectableRows: "none",
    responsive: "simple",
    onRowClick: handleRowClick,
  };

History page: Nothing shows in the state

const History = (props) => {
  const { state } = useLocation(); //document ID here
  console.log(state, "state");


  return (
    <div>
      
    </div>
  );
};

export default History;

App.js

   <Route
            path="/history"
            element={
              <PrivateRoute>
                <Layout>
                  <History />
                </Layout>
              </PrivateRoute>
            }
          />

I do not know what is the problem here since I can just pass another data to my edit-page whenever I'll click the button edit which is present in each row.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

the navigate function takes up to two arguments, the "to" target and an "options" object with state and replace keys.

useNavigate

declare function useNavigate(): NavigateFunction;

interface NavigateFunction {
  (
    to: To,
    options?: { replace?: boolean; state?: any } // <-- options object, state
  ): void;
  (delta: number): void;
}

Move the rowData array element into the options object under the state key.

Example:

navigate("/history", { state: { rowData: rowData[0] } });

Use the useLocation hook on the receiving component to access the route state.

const { state } = useLocation();
const { rowData } = state || {};
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