Я думаю, что это странный вопрос, но у меня есть переменная в React native, например:
const phrases = {
Default: {
title: "Fetching the Weather",
subtitle: "Be patient, you're witnessing a miricle",
highlight: "Fetching",
color: "#636363",
background: "#9C9C9C",
},
Clear: {
title: "It's Amazing Balls",
subtitle: "Rock that shit!",
highlight: "Amazing",
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: "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 Freeze",
subtitle: "You're not supposed to eat it",
highlight: "Brain",
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",
},
}
теперь, когда я пытаюсь получить доступ к Заголовку, как это:
phrases[this.state.weather].title
Я получаю эту ошибку:
undefined не является объектом (оценивает фразы (this.state.weather] .title ')
любой может помочь с этим ??