There are a few ways you could hide the Suggestions component. I think a simple solution would be to create a state attribute called showSuggestions. Then you could show/hide it using React's short circuit syntax. In the render method add { this.state.showSuggestions && <Suggestions results={this.state.results} /> }. Then just use setState whenever you want to change the value of showSuggestions, for example when the user leaves the input field.
There are a few ways you could hide the Suggestions component. I think a simple solution would be to create a state attribute called
showSuggestions
. Then you could show/hide it using React's short circuit syntax. In the render method add{ this.state.showSuggestions && <Suggestions results={this.state.results} /> }
. Then just usesetState
whenever you want to change the value ofshowSuggestions
, for example when the user leaves the input field.sir i am really confusing about setState Assynchronous function (its keep on calling Api even if setState is not change )
i hide the results but if i tried again in its shows no results
thank you sir