equal
deleted
inserted
replaced
|
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 * as notesActions from '../actions/notes-actions'; |
|
9 import NotesList from './NotesList'; |
|
10 import NoteInput from './NoteInput'; |
|
11 |
|
12 class NotesContainer extends Component { |
|
13 render() { |
|
14 const { notes } = this.props; |
|
15 return ( |
|
16 <div> |
|
17 <NotesList notes={notes} /> |
|
18 <NoteInput addNote={this.props.actions.addNote} /> |
|
19 </div> |
|
20 ); |
|
21 } |
|
22 } |
|
23 |
|
24 NotesContainer.propTypes = { |
|
25 notes: PropTypes.instanceOf(Immutable.List).isRequired, |
|
26 actions: PropTypes.object.isRequired |
|
27 } |
|
28 |
|
29 function mapStateToProps(state, props) { |
|
30 return { |
|
31 notes: state.get('notes') |
|
32 }; |
|
33 } |
|
34 |
|
35 function mapDispatchToProps(dispatch) { |
|
36 return { |
|
37 actions: bindActionCreators(notesActions, dispatch) |
|
38 } |
|
39 } |
|
40 |
|
41 |
|
42 export default connect(mapStateToProps, mapDispatchToProps)(NotesContainer); |