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

422
Visualizações
React - is there any performance issue if putting the error dialog in App.js and store error in redux?

I am going to store the current error in redux store, in order to show an Error Dialog.

For the error dialog, it will store in App.js like below:

App.js

import "./styles.css";
import "bootstrap/dist/css/bootstrap.min.css";

import { useSelector } from "react-redux";

import ErrorDialog from "./ErrorDialog";
import ComponentA from "./ComponentA";

export default function App() {
  const error = useSelector((state) => state.error);
  return (
    <div className="App">
      <ComponentA />
      {Object.keys(error).length !== 0 && (
        <ErrorDialog title={error.title} message={error.message} />
      )}
    </div>
  );
}

Every Time I hit an error in any page, dispatch will be used to set the error(such as {title:"myError", message: "134"}) in redux store. The error dialog in App.js will be shown like below:
enter image description here

When I close the dialog, I will use dispatch to set the error to {} so it can be closed.

I am wondering will this lead to performance issue if there are more components? Because the <ErrorDialog/> in App.js need to be re-rendered many time.

Or will there be any better way to handle error?

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