New to React..Going through the examples... Please help if you can
<label>Ice Cream Toppings</label>
{ this.toppings.map(top =>
<div className="form-check" key={ top }>
<input className="form-check-input"
type="checkbox" name={ top }
value={ this.state[top] } <============================================
checked={ this.state.toppings.indexOf(top) > -1 }
onChange={ this.updateFormValueCheck } />
<label className="form-check-label">{ top }</label>
</div>
)}
State is declared as
this.state = {
name: "",
flavor: "Vanilla",
toppings: ["Strawberries"]
}
toppings has array for all selected values,, what's the purpose of this.state[top]?