我的react应用程序中有一个数据表,但是当我向其中输入字符时,我创建的mdbdatatable的搜索框未显示任何结果。我希望表格搜索框返回一些有效搜索值的结果。
componentDidMount(){
axios.get('https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2014-01-01&endtime=2014-01-02')
.then(response =>{
//console.log(response)
this.setState({
posts : response.data.features
},()=>console.log(this.state.posts))
})
.catch(error =>{
console.log(error)
this.setState({
error : 'Error retreiving data'
})
})
}
render(){
const{posts,error} = this.state
const rows = posts.map(post => ({
mag: <div key={post.id} > {post.properties.mag}</div>,
loc: <div key={post.id}>{post.properties.place}</div>
}));
const data = {
columns : [
{
label:'Magnitude',
field:'mag'
},
{
label:'Place',
field:'loc'
}
],
rows
}
console.log("Something Fishy")
return(
<MDBDataTable
striped
bordered
small
data={data}/>