I'm new here in the forum and I'm studying react and I came across a question ..
I have the following files:
App.js
class App extends Component {
constructor(props) {
super(props)
this.state = {
historico:[],
isLoading: false
}
this.loadData = this.loadData.bind(this)
}
loadData() {
this.setState({ isLoading: true })
functions.loadHistorico()
.then((res)=>{
this.setState({historico: res}),
console.log(this.state.historico)
})
}
render() {
return (
<li className="dropdown">
<a href="#" className="dropdown-toggle" data-toggle="dropdown"> Histórico <span className="caret"></span> </a>
<ul className="dropdown-menu">
{this.state.historico.map(this.renderHistorico)}
</ul>
</li>
)
}
}
and Home.js
class Home extends Component {
//>>> aqui tem o constructor(props) {} e componentDidMount() {} etc...
pesquisarTermo() {
functions.salvarHistorico(this.refs.termo.value)
//app.loadData() <=====
}
}
I'm creating a list of a dropdown using the map, however I want to update this list every time I call the searchTermo () function in Home.js.
How do I do this?