1

When I am using BackHandler.exitApp() to close the app and not removing the app from task manager window of the android, when I am again opening the app, it seems before it starts the service init, it start to call service functions. So as a result, I am doing init of this.db = new Datastore({ filename: dbPath, autoload: true, ...options }); , But before it happens the database service is already trying to use this.db, so, as a result, it is saying this.db as undefined.

Can anyone tell me how can I do the init first and then start the services everytime I open the app? Or how can I exit a react native app with completely kill all the tasks?

Ankur Sardar
  • 405
  • 1
  • 6
  • 12

1 Answers1

1

I solved this by this module react-native-exit-app - https://www.npmjs.com/package/react-native-exit-app

It closes the app completely.

But it would be great if someone can explain the question.

Ankur Sardar
  • 405
  • 1
  • 6
  • 12
  • It seems that this is what BackHandler.exitApp() is supposed to do... https://stackoverflow.com/questions/44694356/react-native-backhandler-exitapp-cant-kill-the-apps-process – Yossi Oct 31 '19 at 16:16