Hi everyone,
I think this is a weird question but i have a variable in React native like this :
const phrases = {
Default: {
title: "Fetching the freaking Weather",
subtitle: "Be patient, you're witnessing a miricle",
highlight: "freaking",
color: "#636363",
background: "#9C9C9C",
},
Clear: {
title: "It's freaking Amaze Balls",
subtitle: "Rock that shit!",
highlight: "freaking",
color: "#E32500",
background: "#FFD017",
},
Rain: {
title: "Rain rain please go away",
subtitle: "Stay inside and code all day",
highlight: "away",
color: "#004A96",
background: "#2F343A",
},
Thunderstorm: {
title: "freaking Thunder Strike",
subtitle: "Unplug those devices",
highlight: "Thunder",
color: "#FBFF46",
background: "#020202",
},
Clouds: {
title: "Cloud storage limit reached",
subtitle: "error: 5000 - cirrocumulus",
highlight: "limit",
color: "#0044FF",
background: "#939393",
},
Snow: {
title: "Brain freaking Freeze",
subtitle: "You're not supposed to eat it",
highlight: "freaking",
color: "#021D4C",
background: "#15A678",
},
Drizzle: {
title: "Meh... don't even ask",
subtitle: "What did I just say?",
highlight: "don't",
color: "#B3F6E4",
background: "#1FBB68",
},
Mist: {
title: "Mist title",
subtitle: "Mist sub",
highlight: "Mist",
color: "#B3F6E4",
background: "#1FBB68",
},
}
now when i am trying to access Title like this :
phrases[this.state.weather].title
I get this error :
undefined is not an object (evaluating’phrases[this.state.weather].title’)
any one can help with this ??
EDIT**********************************************
this.state.weather had initial state of ‘…’, it should be Default