Hi !
I use the last version of Expo SDK 37 and Ubuntu Based Linux.
I want to make an app which listen my location using expo-Location.
So, I’ve created my tasks, a basic tasks which dispatch the data into my redux store.
In my component class I call componentDidMount to start Location.startLocationUpdatesAsync :
await Location.startLocationUpdatesAsync('BETA_GPS', {
accuracy: Location.Accuracy.BestForNavigation,
foregroundService: {
notificationTitle: 'bonjour'
}
});
My store is updated every seconds.
But, My component is not rendering. No new render() is called.
Do you have any idea why my render is not refresh ?
I’ve wrote a function with setTimeout which called every 100ms the console.log(this.props.data.length); And data is being well incrementing ! Only in the console but nothing on my view.
import React from 'react';
import { View, ScrollView } from 'react-native';
import { connect } from 'react-redux';
import redux from '../../redux/store';
import * as Location from 'expo-location';
import * as TaskManager from 'expo-task-manager';
import { setLocationData } from '../../actions/Map';
import style from './style';
import FontText from '../../components/FontText';
class HomePage extends React.Component {
async componentDidMount() {
await Location.requestPermissionsAsync();
await Location.startLocationUpdatesAsync('BETA_GPS', {
accuracy: Location.Accuracy.BestForNavigation,
foregroundService: {
notificationTitle: 'bonjour'
}
});
}
render() {
return (
<View style={style.view}>
<View>
<View style={style.textContainer}>
<FontText style={style.text}>
Bonjour {this.props.user.data.firstname ? this.props.user.data.firstname : 'No data'}
</FontText>
</View>
<View>
{/* Km, Duration, XP*/}
</View>
</View>
<ScrollView>
<FontText>
{this.props.map.data.length || 'No data'}
</FontText>
</ScrollView>
</View>
);
}
}
const mapStateToProps = (store) => {
return {
user: store.user,
map: store.map
};
};
const mapDispatchToProps = {
setLocationData
};
export default connect(mapStateToProps, mapDispatchToProps)(HomePage);
TaskManager.defineTask('BETA_GPS', ({ data: { locations }, error }) => {
redux.store.dispatch({
type: 'SET_LOCATION_DATA',
payload: locations
});
});
I hope you have any idea ?
Thanks for your work !
EDIT : if you have any idea how to debug background fetch ?
I can’t see if bg fetch works