import React from 'react'; import PropTypes from 'prop-types'; export default class ContactsList extends React.PureComponent { static propTypes = { showList : PropTypes.bool, contactList : PropTypes.array, conversationList: PropTypes.array, }; static defaultProps = { showList : true, contactList: ['machin', 'bidule', 'chuck norris'], }; constructor(props) { super(props); this.state = { showList : true, contactList : ['machin', 'bidule', 'chuck norris'], conversationList: ['machin', 'bidule', 'chuck norris'], }; } submitCompose() { console.log('submit message'); } toggleList = () => { console.log('toggle'); this.setState((state) => { console.log('state.showList', state.showList); return { showList: !state.showList, }; }); }; render() { // return ( //
// liste de contacts //
// ); const renderedList = this.state.contactList.forEach(elem => { return (
  • {elem}
  • ); }); return (
    Messaging box

    la liste de {this.state.contactList.lengh} contacts

    {this.state.showList && (

    show list

      {renderedList}
    )}
    ); } }