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

[Geolocation] Weird network issue #2014

Closed
josebalius opened this issue Jul 15, 2015 · 2 comments
Closed

[Geolocation] Weird network issue #2014

josebalius opened this issue Jul 15, 2015 · 2 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@josebalius
Copy link

Hey guys,

This has been happening for quite a while and I cannot figure out why. I am going to try to get some sample code together to show the problem but I am hoping someone can shed some light in the meantime.

I have a component that grabs the location on componentDidMount per the docs and sets the position on the store

getState() {
        return {
            results: this.ds.cloneWithRows(SearchStore.getSearchFeed()),
            resultsClean: SearchStore.getSearchFeed(),
            location: SearchStore.getPosition(),
            loading: (this.state) ? this.state.loading : false
        }
    }

componentDidMount() {
        this.setState({loading: true});
        navigator.geolocation.getCurrentPosition(
            (position) => SearchStore.setPosition(position),
            (error) => console.log(error),
            {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
        );

        this.watchID = navigator.geolocation.watchPosition((position) => {
            SearchStore.setPosition(position);
        });
    }

componentDidUpdate(prevProps, prevState) {
        if(this.state.location !== prevState.location) {
            this.setState({loading: true});
            VenueActions.getVenues().then(() => {
                this.setState({loading: false});
            });
        }
    }

SearchStore.setPosition does an emitChange() and componentDidUpdate is firing correctly, VenueActions.getVenues() does an XMLHttpRequest to the server to grab a list of venues, I am debugging that call as well, and I can see it firing, the only problem is that the request doesn't "resolve" unless I change tabs and come back to it, as soon as I do the request fullfills, even though the server sent back the response seconds before (I can see it in the logs).

I was using fetch to do make the calls and tried using XMLHttpRequest and still had the same problem. The thing is on other components where I make XHR calls without using GeoLocation it works great, it only seems to have this "stuck" problem when I grab the location and make a call afterwards.

Interesting enough it doesn't happen on the device, it works great on there.........so I am guessing there is something going with Chrome providing the location? It's not a big deal but I thought I would report it in case we could do something to improve it.

@brentvatne
Copy link
Collaborator

Thanks for reporting @josebalius - always a great idea to track these things in case others have the problem. Definitely a weird one, but as you say it's pretty low priority because it only affects Chrome when fetching Geolocation just before fetch :p

If someone has time to investigate further please post the follow up here!

@brentvatne brentvatne changed the title [GeoLocation] Weird network issue [Geolocation] Weird network issue Jul 21, 2015
@brentvatne
Copy link
Collaborator

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out it's new home: https://productpains.com/post/react-native/geolocation-weird-network-issue

@facebook facebook locked as resolved and limited conversation to collaborators Jul 22, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 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