I have the following setup to render specific parts of the state as {this.state.text}
. It works well enough on it's own, but not if I map it from an object. How do I get the mapped result to reference the state?
object
const data = [
"{this.state.parameters.number} Tips to Get {this.state.parameters.goal}",
"Your Search For {this.state.parameters.goal} Ends Here"
]
state
this.state = {
parameters: {
audience: '{Audience}',
goal: '{Goal}',
number: 6
},
subjectData: data
}
}
map
const subjectLines = this.state.subjectData.map((result, index) =>
<li key={index}>{result}</li>
)
The result of map()
doesn't seem to reference the state at all.
result
{this.state.parameters.number} Tips to Get {this.state.parameters.goal}
Your Search For {this.state.parameters.goal} Ends Here
Whereas the expected result would be:
6 Tips to Get {Goal}
Your Search for {Goal} Ends Here