I have a requirement in which once page gets loaded my dropdownlist
should be populated. for that I put that code in componentDidMount()
.
componentDidMount() {
axios.get(`http://localhost:8080/country_code`).then((res) => {
const countryData = res.data;
this.setState({ countryData });
alert(countryData);
});
}
I have one user input field
in which person enter the value and save
it into database
. I want once user save that value into DB, my dropdown should get refresh and that value should be visible in the dropdown
. so how can I externally call componentDidMount()
? is there any better way to handle the same?
As of now list is getting refreshed only when user resfresh the page
.