reactjs - Fetch not working on React Native Android debug -
i'm trying create simple reactnative app play around graphql , rn on android (i'm familiar getting work on iphone).
but i'm running problem -- root component places get
request api. although request works when spin xcode simulator, fails when run android version on phone.
the android/ios versions identical. 2 index files both use
react-native-router-flux
, identical, , import shared components.
here's simplified code of component:
constructor(props) { super(props); this.state = { source: 'mygraphqlendpoint' } } componentdidmount() { if (this.props.drill) { return null; } this.serverrequest = fetch(this.state.source) .then((result) => result.json()) .then((json) => { this.setstate({ drill: json.data.drill }); }); } componentwillunmount() { this.serverrequest.abort(); } render() { const { drill } = this.state; if (!drill) { return null; } ... view stuff }
on ios simulator, works perfectly. on android phone, never sets state, , doesn't past if (!drill)
line. if instead set state expected api data directly (instead of making actual call), android app works fine (with non-live data).
the phone connected internet.
any idea what's wrong?
ps -- i've tried number of variants, including:
- changing request have 1
.then
, callsresponse.json().data.drill
. - assigning response variable defined outside of request, , setting
state
equal (which sets state looks response buffer[42, 36, ...
can't printed screen.
no dice.
Comments
Post a Comment