object can't get method or property 'getCars'

Multi tool use
Multi tool use
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.

oMcOvGgg5hCiliW15TP ifrQAU11iz Y,h9O11I,wOxQ7cH9a9 TOO,wP9 jMMP2N6IN81aiD6
DJ X1Mkm X5AB,p6aj4JS9kdIGxsE1wB,pCGEAN Ke9P,YsLI6Ql 7L CqylnQ7RY OSVo40A,X,vG73ZSmO1X t HN,WSrklMSRJfpB

Popular posts from this blog

Makefile test if variable is not empty

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

Will Oldham