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

152
Vistas
How to export a variable to another react functional component?

I am creating this react app in which I want to export a variable to another react functional component. I am also facing an issue since when a user clicks on a button, only then will the variable contain value or else it is undefined and exporting an undefined variable is not possible. So I was hoping that there is a way I can export the variable only when it contains a value. Thanks in advance to anyone who has helped!

PS: I am a Beginner :)

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

0

if this variable is defined inside your the function of your component you can't export it


const canExport = 'yes we can'

const App = () => {
    const iAmImpossibleToExport = []

    return <div>The application</div>
}
export { canExport }

export default App 

If you want to pass variables to other components, you can use props, context, redux.... but it's more advanced topics (redux and context) and tools that should be manipulated and used carefully. You probably juste need state and props at your level.

Good luck with you journey into React

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