var Contact = React.createClass({
getInitialState: function() {
return {
isOpened: {
address: '' ,
email: ''
}
}
},
isOpened: function(event) {
this.setState({
isOpened: {
address: this.props.address ,
email: this.props.email}
}
);
},
render:function() {
return (
<li className="contact" onClick={this.isOpened}>
<img className="contact-image" src={this.props.image} width="68px" height="68px"/>
<div className="contact-info">
<div className="contact-name" >{this.props.name}</div>
<div className="contact-number" >{this.props.phoneNumber}</div>
<div>{this.state.isOpened.address}</div>
<div>{this.state.isOpened.email}</div>
</div>
</li>
)
}
});
const emptyContacts = {
address: '' ,
email: '',
}
var Contact = React.createClass({
getInitialState: function() {
return {
contactData: emptyContacts,
}
},
toggleContactsData: function(event) {
this.setState({
contactData: thsi.state.contactsData === emptyContacts
? { address: this.props.address, email: this.props.email, }
: emptyContacts
});
},
render:function() {
return (
<li className="contact" onClick={this.toggleContactsData}>
<img className="contact-image" src={this.props.image} width="68px" height="68px"/>
<div className="contact-info">
<div className="contact-name" >{this.props.name}</div>
<div className="contact-number" >{this.props.phoneNumber}</div>
<div>{this.state.contactData.address}</div>
<div>{this.state.contactData.email}</div>
</div>
</li>
)
}
});