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

145
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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