rgommezz / react-native-offline

Handy toolbelt to deal nicely with offline/online connectivity in a React Native app. Smooth redux integration ✈️
MIT License
2.34k stars 271 forks source link

useIsConnected returns null initially in 6+ #377

Open justinadkins opened 1 year ago

justinadkins commented 1 year ago

Current Behavior

Expected Behavior

How to reproduce

Your Environment

software version
react-native-offline 6.0.2
react-native 0.71.4
node 18
npm or yarn yarn 1.22.19
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

nitesh-habilelabs commented 5 months ago

any update regarding this issue? or any workaround? i am having an issue where if i have added some alerts to check if internet is working or not. so when i launch the app with internet on… i get the alert that internet connected (working as intended) when i turn off internet … gets the alert “you are offline” (working as intended)

but if i turn on internet again….nothing happens at all. after turning off internet once… it doesn’t update anymore.

dabit1 commented 5 months ago

Hi! same issue here. We should be able to control the initial value of the hook, otherwise it is forcing us to add another function to determine what value "null" should be.

dabit1 commented 5 months ago

I have just realized that it returns null only first time it is called. So if in your initial screen you just wait until the value is different than null then all is ok :)

thoughtworks-tcaceres commented 1 month ago

Is there any way to change the "definition" of isConnected? I want it to be more similar to netInfo's where it doesn't necessarily need internet access, so i can avoid pinging entirely.