RN development, in a utility class, I need to export an environment parameter, but this parameter is read asynchronously through AsyncStorage.
import { AsyncStorage } from "react-native"
_retrieveData = async () => {
let result = "prod"
try {
const value = await AsyncStorage.getItem("currentEnv");
if (value !== null) {
// We have data!!
console.log("~~~~", value);
result = value
}
} catch (error) {
// Error retrieving data
console.log("~~~~null");
}
return result
}
var testEnv = ""
_retrieveData().then((env) => testEnv = env)
export const curEnv = testEnv
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)