Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!