I have a object which has an array inside it. Each array has multiple objects. So using the .map function I am looping over the array inside the object. Each array item has a click function where I toggle the item. Initial state of the array item is this
{ DisplayText: "Foresatte" Selectable: true UserRecipientToInclude: "IncludeGuardianRecipient"}
When I do this
choice.Selected = false
and console logs the result the newly added item is not present in the object. Why is that?
Here is the code
<TouchableHighlight {...testProperties(choice.DisplayText, true)} style={{ opacity: !choice.Selectable ? 0.4 : 1 }} onPress={() => { this.selectChoice(c.UserDropdownMenuChoices, choice, c) }} underlayColor={'transparent'} key={choice.DisplayText}><View style={styles.choiceContainer}> { choice.selected ? ( //<MaterialCommunityIcons name={'checkbox-marked'} style={styles.checkboxClick} size={20} /><Icon type={'material-community'} name={'checkbox-marked'} iconStyle={styles.checkboxClick} size={20} /> ) : (<Icon type={'material-community'} name={'checkbox-blank-outline'} iconStyle={styles.checkboxDefault} size={20} /> ) //DONE: <MaterialCommunityIcons name={'checkbox-blank-outline'} style={styles.checkboxDefault} size={20} /> }<Text style={styles.displayText}>{choice.DisplayText}</Text></View></TouchableHighlight>
and my function is like this
selectChoice(choicesList, choice, contact) { choice.selected = true ... console.log(choice) // doesn't have the new property }
This code is for a react native application