I'm adding a search bar to a page in my movie review application. The page displays all the review posts for one specific movie. The prop "reviews" contains all the existing reviews. I was stuck with figuring out how to pass the value of the state "filteredResults" from the useSearch hook to the ReviewPost component so that I could display the filteredResults data on the page.
CodePudding user response:
You need to move const { onChange, textValue, filteredResults } = useSearch({ reviews })
to Parent component and from Parent pass props onChange, textValue
to ReviewSearchBar
and prop filteredResults
to ReviewPosts
component
CodePudding user response:
I recommend using Redux to manage global state.