HeaderSearchBar hidden after navigation via router.replace #11923
Unanswered
lordpotato89
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi community,
I have a searchbar on my main page for searching and adding items. It is integrated via
import { useNavigation } from "expo-router"
const navigation = useNavigation()
useLayoutEffect(() => {
navigation.setOptions({
headerSearchBarOptions: {
placeholder: "Search and add bike",
onChangeText: (event) => handleInputChange(event.nativeEvent.text),
onFocus: (event) => setIsSearchbarFocused(true),
onBlur: (event) => setIsSearchbarFocused(false),
},
})
}, [navigation])
In order to return to my initial list of items on my main page I use
router.push("/main") which cancels the search, unfocuses and clears all search results. My problem is now, that the search bar is not showing on the initial render after navigation, the user has to scroll in order make it visible again. Any ideas why and how to fix it? On all other navigation usecases it is shown on initial render. Since expo is built on top of react navigation maybe somebody knows the answer in this forum.
Thanks in advance
Regards
Mati
Beta Was this translation helpful? Give feedback.
All reactions