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

NetInfo.isConnected, it's "change" event should not trigger on componentWillMount #11041

Closed
jinlong opened this issue Nov 21, 2016 · 1 comment
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@jinlong
Copy link

jinlong commented Nov 21, 2016

when component will mount, two "console.log" are output. but i don't change the network

code as follow:

componentWillMount() {
    NetInfo.isConnected.fetch().done(isConnected => {
        console.log('First, is ' + (isConnected ? 'online' : 'offline'));

    });
    
    NetInfo.isConnected.addEventListener('change', (isConnected) => {
        console.log('Then, is ' + (isConnected ? 'online' : 'offline'));
        
    });
    
}

run result:

11-21 18:30:28.285 14419-23251/com.android.browser I/ReactNativeJS: Then, is online
11-21 18:30:28.335 14419-23251/com.android.browser I/ReactNativeJS: First, is online
@mkonicek
Copy link
Contributor

Can you provide a minimal amount of code to reproduce this on rnplay.org? This is necessary for people to be able to see and debug the issue being reported.

Closing this issue as it is not actionable. Please open a new one with an rnplay link (preferred), or link to a GitHub repo with clear instructions how to repro.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants