The Following code displays the list of countries when component is rendered for the first time.
<select onChange={this.handleLocation} data-live-search="true" className="selectpicker" data-selected-text-format="count" data-size="7" title="Select Country" >
{ getNames() && getNames().map(
(e, id) => {
return <option key={e} >{e}</option>
})
}
</select>
Note: bootstrap-select
is used.
When component is loaded for the first time, the list of countries are displayed properly. But when button is clicked, I am redirecting to another component using
this.props.push('/searchresults')
After pressing back, the component is loaded perfectly but the list of countries are not rendering to the component.
Whats wrong with my code.
FYI: npm i country-list --> Package to get countries
Thanks in advance