0

I have a react native app and I'm using an android native module to run a long task. While this task is going on, I would like to show a progress bar in my react native screen while this task is going on. How do i do this? I'm currently only able to get a callback once my long running task is over.

I want to be able to show meaningful progress. Like 10% done. Not just a loading spinner.

Jeff P Chacko
  • 4,908
  • 4
  • 24
  • 32

1 Answers1

0

This requires that your native module is constantly emitting to the js context the progress, like 5%, 10% etc. (Check official docs about how to do the emission). Then, subscribing to this event, you can update your progress bar with the actual percentage. I would use the paper's progressBar.

Of course, if your task is timed-based, i.e you know it will finish after 2 seconds, you can just add an interval on the js side and update accordingly the progressBar, i.e every 100ms you can progress it by 5%.

angelos_lex
  • 1,593
  • 16
  • 24