I have integrated the search filter and retrieved the json data( array of objects ) using the post method based on the search term. The json output is given below:
[
{"taxi_code":"CT0001","class":"0"},
{"taxi_code":"CT0002","class":"0"},
{"taxi_code":"CT0003","class":"0"}
]
But the json data is not rendered to the DisplayTable component even using map method. What i did wrong?? Using console.log(<DisplayTable data={queryResult} />), i got this type of output: Object { props={...}, _store={...}, $$typeof=Symbol {}, more...}
class Results extends Component
{
constructor(props){
super(props);
this.state={searchTerm:''};
}
render(){
return(<div id="results" className="search-results">
{this.props.data}
<SearchInput className="search-input" onChange={e=>this.searchUpdated(e)} />
</div>);
}
searchUpdated (e) {
this.setState={searchTerm: e};
var queryResult;
axios.post(config.api.url + 'public/getAttributesbyname', {'searchTerm':e,'name':this.props.data})
.then(response => {
var queryResult = response.data;
render()
{
return (<DisplayTable data={queryResult}/>);
}
})
.catch(response => {
});
}
}
class DisplayTable extends Component
{
render()
{
return this.props.data.map((alldata)=> {
return <div className="station">{alldata.taxi_code}</div>;
});
}
}