I am getting the above error when using AsyncStorage.
const defaultCity = {
name: "Tbilisi",
id: "22sH7BDcVH7MOYOtvqbD",
};
const [city, setCity] = useState(defaultCity);
const [cityInitialized, setCityInitialized] = useState(false);
const getStoredCity = async () => {
try {
const city = await JSON.parse(AsyncStorage.getItem("city"));
if (!city) {
setCityInitialized(true);
} else {
setCity(city);
setCityInitialized(true);
}
} catch (error) {
AsyncStorage.removeItem("city");
console.log(error);
setCity(defaultCity);
}
};
My object defaultCity
should be able to be stringified unlessI'm missing something.