In state I have an array of objects, each with the same properties, different values.
- QuoteApp Component:
state = {
quotes: [
{
quoteText: "When you can't find the sunshine, be the sunshine!",
quoteAuthor: 'Person 1'
},
{
quoteText: 'The grass is greener where you water it',
quoteAuthor: 'Person 2'
}
]
}
In another component I am passing a new object to QuoteApp, but now it only has the quoteText property.
This is what I'm passing to QuoteApp:
Object { quoteText: "I am the one who knocks!" }
So how can I use setState to "concat" the new object to the initial object in state (modifying only the QuoteText property and leaving the second intact)?
quoteTextproperty, then you may push new quote to array that corresponds to necessary author, but you're going to need to passquoteAuthoras well to know where exactly to add new quote.quoteText?quoteAuthormay serve as a key if you're not worried there could be couple of Charles Dickens' or a bunch of Benjamin Franklin's