I have the following component that shows the options of a quiz, when the user select a value I want to pass the "item.id" selected in the "handleNext", no código abaixo aparece o seguinte erro:
Uncaught ReferenceError: item is not defined
code:
render () {
return (
<UserContext.Provider value={this.state}>
<UserContext.Consumer>
{({ current_statement, current_alternative, handleNext}) => (
<form>
<p>{current_statement}</p>
{this.state.current_alternative.map(item => (
<React.Fragment key={item.id}>
<div>
<input id={item.id} type="radio" name="question"/>
<label htmlFor={item.id}>{item.content}</label>
</div>
</React.Fragment>
))}
<button onClick={(e) => this.handleNext(e, item.id)} type="button">Next</button>
</form>
)}
</UserContext.Consumer>
</UserContext.Provider>
)
}