There are two tormenting questions:
There is a piece of render code
var data = this.props.data; var hidden = this.state.hidden; var template = data.map(function(item,index) { return( <div className="mainDiv" key="{index}"> <p className="feedText">{item.author}</p> <p className={'feedText ' + 'smallmargin'}>{item.text}</p> <p className={'feedText ' + 'smallmargin ' + (hidden ? '' : 'hidden')}>{item.bigtext}</p> </div> ) });The reaction refuses to render because {index} is used twice, it must be unique, but the index value is different - 0 and 1. How to be in this situation?
How to tie event? There is an event
divClick : function(e) { e.preventDefault(); this.setState({hidden : true}); }Banal onclick says divClick undefined
<div className="mainDiv" onClick={this.divClick}>
What are the problems?