import the React from 'React';OnChange={this. HandleSearchChange}
The import Axios from 'Axios';
The import Card from '/Card';
The import '../CSS/main CSS '
The import 'font - awesome/CSS font - awesome. Min. CSS';
The class Main extends ponent {
React.Com
State={
CARDS: [],
Keyword: "'
}
ComponentDidMount () {
Enclosing retreiveData ();
}
RetreiveData ()==https://bbs.csdn.net/topics/> {
Axios. Get (` ${process. The env. REACT_APP_API_URL}/CARDS `)
Then (response=& gt; {
This. State={CARDS: the response data};
Enclosing setState (enclosing state)
})
The catch (function (error) {
The console. The log (error. The response)
})
}
HandleSearchChange=(e)=& gt; {
The console. The log (this) state) keyword)
Enclosing setState ({keyword: e. arget, value})
}
HandleSearchSubmit=(e)=& gt; {
E.p reventDefault ();
Enclosing retreiveData ();
Let newData=https://bbs.csdn.net/topics/[];
Var data=https://bbs.csdn.net/topics/this.state.cards
Data. The map ((item)=& gt; {
If (item.com panyName. IndexOf (this. State. Keyword) & gt;=0) {
NewData. Push (item)
}
});
The console. The log (newData)
Enclosing setState ({CARDS: newData}, ()=& gt; {
The console. The log (this) state) CARDS)
})
The console. The log (this) state) CARDS)
}
Render () {
Return (
<>
/>