client/src/components/NotesContainer.js
changeset 12 48ddaa42b810
parent 11 6fb4de54acea
child 13 d6eef0e9f7e1
equal deleted inserted replaced
11:6fb4de54acea 12:48ddaa42b810
     1 import React, { Component } from 'react';
       
     2 import {connect} from 'react-redux';
       
     3 import {bindActionCreators} from 'redux';
       
     4 
       
     5 import PropTypes from 'prop-types';
       
     6 import Immutable from 'immutable';
       
     7 
       
     8 import { Grid, Row, Col} from 'react-bootstrap';
       
     9 
       
    10 import * as notesActions from '../actions/notesActions';
       
    11 import NotesList from './NotesList';
       
    12 import NoteInput from './NoteInput';
       
    13 
       
    14 class NotesContainer extends Component {
       
    15     render() {
       
    16         const { notes } = this.props;
       
    17         return (
       
    18           <Grid>
       
    19             <Row>
       
    20               <Col xs={12} md={12}>
       
    21                 <NotesList notes={notes} />
       
    22               </Col>
       
    23             </Row>
       
    24             <Row>
       
    25               <Col xs={12} md={12}>
       
    26                 <NoteInput addNote={this.props.actions.addNote} />
       
    27               </Col>
       
    28             </Row>
       
    29           </Grid>
       
    30         );
       
    31     }
       
    32 }
       
    33 
       
    34 NotesContainer.propTypes = {
       
    35     notes: PropTypes.instanceOf(Immutable.List).isRequired,
       
    36     actions: PropTypes.object.isRequired
       
    37 }
       
    38 
       
    39 function mapStateToProps(state, props) {
       
    40   return {
       
    41     notes: state.get('notes')
       
    42   };
       
    43 }
       
    44 
       
    45 function mapDispatchToProps(dispatch) {
       
    46   return {
       
    47     actions: bindActionCreators(notesActions, dispatch)
       
    48   }
       
    49 }
       
    50 
       
    51 
       
    52 export default connect(mapStateToProps, mapDispatchToProps)(NotesContainer);