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 paste a segment of code from another file?

This might be a weird question to ask but is there a way to paste/import a segment of code from another file?
for example:

file1.js:

export default function App() {
  return (
   some_paste_function('file2.js');
  );
}

file2.js:

<View>
       <View>
         <Text>Hello World</Text>
      </View>
</View>

basically the some_paste_function(file_name); just pastes the content of the file2.js in the functions place, it's more for making the file system look cleaner rather than using import

is there such a function or anything similar to it in react native or even js in general?

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

0

Technically you can use require to dynamically load contents from another file, if they are exported from it, and only if you're running on a module loader that uses it.

export default function App() {
  return require("./file2.js");
}
export default function Component() {
  return <View>
    {/* ... */}
  </View>;
}

However, I'd strongly advise against it, as you lose the benefits of proper type checking, auto-refactoring and your dependancy graph gets messy.

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