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

247
Vistas
Component memoized with React.memo() keeps re-rendering

I have a ParentComponent looking like this:

const ParentComponent = () => {
  [product, setProduct] = useState({
    name: "Test",
    description: "Information goes here..."
  })

  return(
    <ChildComponent product={product} updateProduct={setProduct}/>
  );
}

and a ChildComponent as follows:

const ChildComponent = ({product, updateProduct}) => {
  // some code here

  return(
    <RichTextEditor content={product.description} update={updateProduct}/>
  )
}

const isEqual = () => {
  return true; // I want to force the component to never re-render
}

export default React.memo(ChildComponent, isEqual)

What's happening here is that I have a product object with a description that is updated by the ChildComponent. The value for the description gets set via updateProduct every time the input changes in the RichTextEditor component. I understand that because of the state change of product the ChildComponent gets re-rendered everytime which is unfortunate because that can cause unwanted effects like making the input field inside RichTextEditor lose focus for example. So I tried forcing the ChildComponent to never re-render with my isEqual function that always returns true. It keeps re-rendering though, why is that?

I realize that there are other designs available to avoid this issue completely, and I'm probably going to do that anyways but before I do that I want to understand why I can not force ChildComponent to not re-render.

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

0

If you are using useState, useContext or useReducer then the component will still re-render.

This is straight from the docs.

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