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.