client/src/components/NotesList.js
changeset 168 ea92f4fe783d
parent 161 a642639dbc07
child 170 7da1d5137b0b
equal deleted inserted replaced
167:1f340f3597a8 168:ea92f4fe783d
     1 import React, { Component } from 'react';
     1 import React, { Component } from 'react';
     2 import PropTypes from 'prop-types';
     2 import PropTypes from 'prop-types';
     3 import Immutable from 'immutable';
       
     4 import Modal  from 'react-modal';
     3 import Modal  from 'react-modal';
     5 import Note from './Note';
     4 import Note from './Note';
     6 import './NoteList.css';
     5 import './NoteList.css';
     7 
     6 
     8 class NotesList extends Component {
     7 class NotesList extends Component {
    14       modalIsOpen: false,
    13       modalIsOpen: false,
    15     }
    14     }
    16   }
    15   }
    17 
    16 
    18   componentDidUpdate(prevProps) {
    17   componentDidUpdate(prevProps) {
    19     if ((this.props.notes || []).size > (prevProps.notes || []).size) {
    18     if ((this.props.notes || []).length > (prevProps.notes || []).length) {
    20     this.node.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"})
    19       this.node.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"})
    21     }
    20     }
    22   }
    21   }
    23 
    22 
    24   componentWillMount() {
    23   componentWillMount() {
    25     Modal.setAppElement('body');
    24     Modal.setAppElement('body');
   113     );
   112     );
   114   }
   113   }
   115 };
   114 };
   116 
   115 
   117 NotesList.propTypes = {
   116 NotesList.propTypes = {
   118   notes: PropTypes.instanceOf(Immutable.List).isRequired
   117   notes: PropTypes.array.isRequired
   119 };
   118 };
   120 
   119 
   121 export default NotesList;
   120 export default NotesList;