I am trying to setState on something that may be true false or null. I am having issues and looking for a clean way to code
does not work
setFullCalendar(await AsyncStorage.getItem('@calendar') === 'true' || null ? true: false);
Works but I can not set if null
setFullCalendar(await AsyncStorage.getItem('@calendar') === 'true' ? true: false);
Works but not clean. (not clean because I have over 10 of these todo)
const checkStorage = await AsyncStorage.getItem('@calendar')
if(checkStorage == 'true'){
setFullCalendar(true)
} else if (checkStorage !== null){
setFullCalendar(true)
} else{
setFullCalendar(false)
}