Rather than writing a detailed article here, I would like to point out very few performance tuning technique with respect to React Native Navigation using react-navigation package.
1. Few check you have to do before blaming react-navigation library, Check whether are you calling any location api to fetch current location.
If you are fetching current location on component mount or will mount then consider my suggestion , fetch the current location on launch of app and save the location, then onwards use the saved location rather than fetching current location every time.
Find the code here to do so
import { AsyncStorage } from 'react-native';
let instance = null;
class SharedPreferences {
constructor() {
if (!instance) {
instance = this;
}
return instance;
}
async put(key, val) {
try {
await AsyncStorage.setItem(key, val);
} catch (error) {
console.error('Unable to save in preferences: ', error);
}
}
async get(key) {
try {
return await AsyncStorage.getItem(key);
} catch (error) {
console.error('Unable to get from preferences: ', error);
}
}
getMultiple(keys, callback) {
AsyncStorage.multiGet(keys, (err, stores) => {
if (!err) {
const keyVals = {};
stores.map((result, i, store) => {
keyVals[`${result[0]}`] = result[1];
});
callback(keyVals);
} else {
callback([]);
}
});
}
}
const sharedPreference = new SharedPreferences();
export const SHARED_PREFERENCE = {
accessor: sharedPreference
};