DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Alberto Peral
Alberto Peral

Posted on

How to persist countdown in background react native expo

I've tried use a countdown in background in react native expo, i use webview:

<WebView
        onMessage={() => {

            if (props.initialHour >= finishHour) {
                props.setMinutes(null);
                props.stopSound();
            }
        }}
        source={{
            html: `<script>
          setInterval(()=>{window.ReactNativeWebView.postMessage("");}, ${props.interval})
          </script>`,
        }}
    />
Enter fullscreen mode Exit fullscreen mode

but only persist interval 5min in background and i've tried setTimeout too and the same results.

How can i do it? without using expo eject

Please help me :( and thank you!

Top comments (0)

Join us at DEV
Yes, this is technically an β€œad”, but really we just want to ask if you want to join DEV. We have 900k+ developers reading, posting, and enjoying community, and would love to have you. Β  Create an account and continue your coding journey.