@@ -3,7 +3,6 @@ import { connect } from 'react-redux'
33import Input from '../components/Input'
44import * as MoviesAction from '../actions'
55import { bindActionCreators } from 'redux'
6- import '../style/main.css' ;
76
87class InputSet extends Component {
98 constructor ( props ) {
@@ -17,15 +16,19 @@ class InputSet extends Component {
1716 this . handleResponse = this . handleResponse . bind ( this )
1817 }
1918
19+ // Function for when 'search' is clicked and retrieves movies
2020 handleResponse ( input ) {
2121 const { retrieveMovies } = this . props ;
22+ // eslint-disable-next-line
2223 const result = retrieveMovies ( input ) ;
2324 }
2425
26+ // Function for when text in input changes
2527 handleChange ( e ) {
2628 this . setState ( { input : e . target . value } ) ;
2729 }
2830
31+ // Function for 'enter' key press
2932 handleKeyPress ( target ) {
3033 const { input } = this . state ;
3134 if ( target . charCode === 13 ) {
@@ -35,7 +38,6 @@ class InputSet extends Component {
3538
3639 render ( ) {
3740 const { input } = this . state ;
38- const { handleResponse } = this . props ;
3941 return (
4042 < div className = "input-set" >
4143 < Input movieValue = { input } handleChange = { this . handleChange } handleKeyPress = { this . handleKeyPress } handleResponse = { this . handleResponse } />
@@ -44,17 +46,20 @@ class InputSet extends Component {
4446 }
4547}
4648
49+ // Set state and action as proptype
4750InputSet . propTypes = {
4851 movies : PropTypes . object ,
4952 retrieveMovies : PropTypes . func
5053}
5154
55+ // Map Redux state to props
5256function mapStateToProps ( state ) {
5357 return {
5458 movies : state . movies
5559 } ;
5660}
5761
62+ // Map action to props
5863function mapDispatchToProps ( dispatch ) {
5964 return bindActionCreators ( Object . assign ( { } , MoviesAction ) , dispatch ) ;
6065}
0 commit comments