Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useIsConnected returns null initially in 6+ #377

Open
justinadkins opened this issue Apr 12, 2023 · 5 comments
Open

useIsConnected returns null initially in 6+ #377

justinadkins opened this issue Apr 12, 2023 · 5 comments

Comments

@justinadkins
Copy link

justinadkins commented Apr 12, 2023

Current Behavior

  • I recently started using 6.0.2 and have noticed that useIsConnected will return null prior to the first "check". This breaks a lot of assumptions that I had from 5.X since it defaulted to true previously.
  • I now need to do a bunch of null checks to prevent running logic that was only intended for false

Expected Behavior

  • I expect the value to be true until we have determined that it is false.
  • I expect the typing for useIsConnected to reflect what it will return
    • Update: the typing is correct, VSCode let me down

How to reproduce

  • Repro can be found here

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
Copy link

stale bot commented Jun 18, 2023

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.

@stale stale bot added the wontfix label Jun 18, 2023
@nitesh-habilelabs
Copy link

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.

@stale stale bot removed the wontfix label May 23, 2024
@dabit1
Copy link

dabit1 commented Jun 5, 2024

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
Copy link

dabit1 commented Jun 5, 2024

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants