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

511
Vistas
Is there a difference between modifying properties via React.createContext() or value property?

Say you have the following code:

//App.js

//logoutHandler function defined here

function App {

const testContext = React.createContext({
  isLoggedIn: false, 
  onLogout: logoutHandler
}) 

return (
  <testContext.Provider>
  //Some code with components
  </testContext.Provider>
 )
}

Other than the fact that the values in the value property override the default values, is this any different than setting the value property in testContext like:

//App.js 

//logoutHandler function defined here

function App {
return (
  <testContext.Provider 
  value = {{
    isLoggedIn: false
    onLogout: logoutHandler 
  }}
  >
  //Some code with components 
  </testContext.Provider>
}

Thanks.

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

0

Passing value prop through the Provider is useful in many ways:

  1. Providers can be nested to override values deeper within the tree. So, you can have different values for different nodes deeper into the tree.

  2. Consumers that are descendants of a Provider will re-render whenever the value prop of the Provider changes.

You can't do this with the default value. The defaultValue stays the same and doesn't cause re-renders.

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