object can't get method or property 'getCars'

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


object can't get method or property 'getCars'



i'm working on react-redux intermidiate..but i don't know what's going wrong
on this project



hera i have creacted the searchbar for getting car details..and the file is created as 'search.js'...you can see here..



search.js


import React, { Component } from 'react';
import { connect } from 'react-redux';
import { getCars } from '../actions';
import { bindActionCreators } from 'redux';

class Search extends Component{
constructor(props){
super(props);

this.state = {
keyword:''
}
}

searchCars = (event) => {
event.preventDefault();
this.props.getCars(this.state.keyword)
}

handleChange = (event) => {
this.setState({
keyword:event.target.value
})
}

componentDidMount(){
console.log(this.state);
}

render(){
return(
<div className="main_search">
<form onSubmit={this.searchCars}>
<input type="text" value={this.state.keyword} onChange = {this.handleChange} />
</form>
</div>
)
}
}

// mapStateToProps
// mapDispatchToProps

function mapDispatchToProps(dispatch){
return bindActionCreators({getCars}, dispatch)
}

export default connect(null,mapDispatchToProps)(Search);



and i think error comes from here about getCars..which is described below as s 'index.js'...you can see here



index.js


const URL_ROOT = 'http://localhost:3004'

export default function getCars(keywords){
const request = fetch(`${URL_ROOT}/carsIndex?q=${keywords}`,
{method:'GET'})
.then(response => response.json())

return{
type:'SEARCH_CARS',
payload:request
}
}



and the error looks like this..
error



and error showing in bundle.js file
enter image description here



so try to fix it and help me...









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results