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

258
Views
How to add react-native-background-thread to the code?

I am very new to React-Native and JS. Any help or suggestions will be appreciated.

I want to add a background thread to the code and my teammate came across this library https://www.npmjs.com/package/react-native-js-background-thread. After reading the description we decided to go for this as we don't need some fancy library that runs thread in the background even the app is closed or in the background.

There is runAsync method that need to called to run the thread I suppose. I having hard time implementing it. Can someone explain with an example please?

This is how I am trying to use:

const runMe = (a, b) => {
 let count=0;
 for(let i=0; i<a; i++){
  for(let j=0; j<b; j++){
   count++;
  }
 }
 return JSON.stringify(count);
};

runAsync(this.runMe, 'runMe', [200000, 10000])
 .then(result => {
        console.log('output: ', result);
 });

And I am getting the following error:

ERROR TypeError: null is not an object (evaluating 'RNReactNativeJsBackgroundThread.runAsyncCode')

ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.

This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

about 4 years ago · Juan Pablo Isaza
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!