DEV Community

Discussion on: How to Create a Truly Reusable React Component from Scratch

Collapse
sameeravhad119 profile image
sameeravhad119

Hi, I really likes your all the post. You explain very well and in simple language.🙂
I have following doubt.
Search input field is controlled component. It is controlled by searchTerm state. It is setting in onchange only.
But I think we need to set it in handleSuggestionClick function also.
That means , if searchTerm= 'can'
And if I choose Canada from suggested drop down.
Then , selectedCountry = Canada ( which you are doing). But searchTerm= Canada ( I think you missed this in coding. Still it is 'can' only in coding).
Correct me if I wrong.