I have a parent called main_homepageComponent and two child search_barComponent & Iteams_Component
I want to do something like this:-
When a user puts some text in search-box(input text) of search_barComponent I want to hide Iteams_Component
Hierarchy:-
--main_homepageComponent
--search_barComponent
--Iteams_Component
Currently, I am trying to create a state variable in my search_barComponent, and when the user input some text then:-
const [search, setSearch] = useState('') //extra code removed
onChangeText={(text) => {setSearch(text)}}
and in my main_homepageComponent I added something like this:-
const [search, setSearch] = useState('') //extra code removed
<ScrollView style={{ height: windowHeight }}>
{search.length < 1 ? (
<View>
<ItemsComponent></ItemsComponent>
</View>
) : null}
</ScrollView>
But I do not know how can I send back the search value from search_barComponent to main_homepageComponent so I can run
{search.length < 1 ? (
<View>
<ItemsComponent></ItemsComponent>
</View>
) : null}
</ScrollView>
this and hide Iteams_Component when user input text in searchbox.
Please provide an answer for functional components because I do not understand the class component much
This is my app image:-
