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

201
Visualizações
State change causing rerendering of the APP component

I added an onChange event to the Editor.js file, it sets the value of the value variable using setValue that causes rerender of the App component on every change. Values of both value and query are needed in Editor.js and Sidebar.js. Is there any better way to do this to improve the performance?

App.js Code:

import React, { Suspense, useState } from "react";
import "./assets/output.css";
import Footer from "./components/layouts/Footer";
import Navbar from "./components/layouts/Navbar";
import Sidebar from "./components/layouts/Sidebar";
import TableSection from "./components/table/TableSection";

const Editor = React.lazy(() => import("./components/editor/Editor"));

const App = () => {
  const [query, setQuery] = useState("");
  const [value, setValue] = useState("select * from customers");

  return (
    <div className="grid grid-cols-layout-desktop grid-rows-layout-desktop bg-gray-600 h-screen">
      <Navbar />
      <Sidebar setQuery={setQuery} setValue={setValue} />
      <Suspense fallback={<div>Loading..</div>}>
        <Editor setQuery={setQuery} value={value} setValue={setValue} />
      </Suspense>
      {query ? <TableSection query={query} /> : null}
      <Footer />
    </div>
  );
};

export default App;
about 4 years ago · Juan Pablo Isaza
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