-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search bar not rendering on iOS or Android on initial render #11627
Comments
Hey @homit-dalia! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro. The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue. You can provide a repro using any of the following:
A snack link is preferred since it's the easiest way to both create and share a repro. If it's not possible to create a repro using a snack, link to a GitHub repo under your username is a good alternative. Don't link to a branch or specific file etc. as it won't be detected. Try to keep the repro as small as possible by narrowing down the minimal amount of code needed to reproduce the issue. Don't link to your entire project or a project containing code unrelated to the issue. See "How to create a Minimal, Reproducible Example" for more information. You can edit your original issue to include a link to the repro, or leave it as a comment. The issue will be closed automatically after a while if you don't provide a repro. |
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
Any update on this? |
@Acetyld I initially set headerSearchBarOptions to true as the documentation stated that you should render atleast the UI elements in stack screens if you will update it on screen mount through .setOptions in useEffect (functional components). That was the problem. I removed headerSearchBarOptions in stack screen entirely and and now declaring it directly through .setOptions. I don't know if this is expected or headerSearchBarOptions : true is for a different context. |
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
Any updates or workarounds? :/ |
I’m sorry @Robert27, but it fixed it for me after I removed headerSearchBarOptions: true in declaration and rebuilt the app. However, it could also be an issue with if you are rendering other icons in headerRight. Try playing around the placement of those icons and see if it works. |
Still not working for me with the latest versions. What about you guys? |
Hey guys, I think I fixed it by setting const navigation = useNavigation<Screen>()
useLayoutEffect(() => {
navigation.setOptions({
headerSearchBarOptions: {
placeholder: 'Search...',
onCancelButtonPress: actions.stopSearching,
onFocus: actions.startSearching,
onChangeText: (e) => actions.onChangeText(e.nativeEvent.text),
hideWhenScrolling: false,
},
})
}, [actions, navigation]) Let me know if this fixes it for you. Be sure to also have your scrollable component as the root node of your screen (not wrapped in a |
@nandorojo I have still the issue on Android, but works on ios. |
I have this problem on Android only. Adding the
|
Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it. |
Hi, I have the same problem. Did you solve the problem? 🙏🏻 |
No, I haven't found a way around this problem. So I temporarily worked around a search modal for Android... |
With expo-router 3.4.1 using: The issue is resolved |
It turns out there was an issue with |
@sidorchukandrew Hi 👋🏻, I using react-native-navigation on my expo project. When use headerSearchBarOptions not showing search icon on screen header. As you said, when I change the react-native-screens version to 3.26.0, the application stays in the splash screen, which means it crashes. So I'm using the latest version but again the search function still doesn't work. Thank you for your interest 🙏🏻 "dependencies": {
"@expo/vector-icons": "^13.0.0",
"@react-native-async-storage/async-storage": "1.18.2",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"@reduxjs/toolkit": "^2.0.1",
"@shopify/flash-list": "1.4.3",
"expo": "~49.0.15",
"expo-font": "~11.4.0",
"expo-splash-screen": "~0.20.5",
"expo-sqlite": "~11.3.3",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-gesture-handler": "~2.12.0",
"react-native-reanimated": "~3.3.0",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "^3.29.0",
"react-redux": "^9.0.4"
} useLayoutEffect(() => {
navigation.setOptions({
headerLargeTitle: true,
headerSearchBarOptions: {
inputType: "text",
cancelButtonText: "İptal",
tintColor: colors.primary,
placeholder: "Ürün ara",
onChangeText: (event) => {
setSearch(event.nativeEvent.text);
},
onFocus: () => {
setIsSearchFocused(true);
},
onBlur: () => {
setIsSearchFocused(false);
},
hideWhenScrolling: false
}
});
}, [navigation, colors]); |
For me it’s not, I have the same versions. While Android is fixed, it started to appear on iOS. Now search bar is not rendered on initial render somehow. |
I doubt this is true. Because the problem lies in the native layer. Expo system relies on stable versions of libraries (mainly major outputs) from version to version of Expo SDK. Therefore, I think that it is worth waiting for the update along with the Expo SDK update to version 50. There will most likely already be support for React Navigation 7. For now, I see as an alternative option to write a plugin for Expo, which will improve the work of the package. |
It is resolved with Expo 50 still in preview but should be released in a couple of weeks. As mentioned above the bug is in another library. |
No it’s definitely not resolved in expo sdk 50 using the latest versions of the libs. |
Is there a link to MR in react-native-screens to make sure that Expo 50 will merge the solution to the problem? |
Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it. |
Lets keep it open, still present |
Not sure if this helps to debug, but maybe someone find useful as workaround. For me issue fixes itself if I remove
Component:
Here are my dependencies:
Here are screen recordings 1) Without passing refreshing and onRefresh, 2) With refreshing and onRefresh https://github.com/react-navigation/react-navigation/assets/19210348/3ab9bd7a-8eaf-436e-884e-fccccbfe4545 Let me know if there is anything I can provide to help it debug |
It didn't make any difference. The basic repo case in issue #10956 has no FlatList |
For me, if I remove |
PLEASE FIX THIS PROBLEM!!!!!!!!! I NEEED HELP |
Yep, i m also trying to show and hide search bar but it is so buggy. When state change it says that i need to use useLayoutEffect.... can u add function for show/hide useLayoutEffect(() => {
if(events.planner.events.length > 0) {
navigation.setOptions({
headerSearchBarOptions: {
placeholder: 'Search...',
hideWhenScrolling: false,
tintColor: theme.colors.primary,
textColor: theme.colors.text,
hintTextColor: theme.colors.textLight,
onSearchButtonPress: ({ nativeEvent }) => {
console.log('Search submitted:', nativeEvent.text); // Handle search submission
},
onChangeText: (e) => setSearchQuery(e.nativeEvent.text),
},
});
}
}, [navigation, events.planner.events.length]);
`
|
I'm also running into this issue. Are there any temporary workarounds? This issue has been open for a long while. |
hm im thinking to set different route if there is records or not... |
Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it. |
Using hideWhenScrolling in screenOptions of a Stack.Navigator in iOS reproduce this wrong behaviour also for me. |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
Still facing same issue, on Android is not working |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
This helped, just using |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
I also still want a solution. |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
1 similar comment
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
Experiencing it on Expo 51, had to set Edit: Disregard that, not helping either |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
I am still having this issue, only on android, with react native v0.74.5 |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
Fixed the issue I was having on Android by using the isFocused hook
Seems like the issue was due to me having multiple bottom tabs with search bars and lazy loading turned off. The headerSearchBarOptions would try to set when the screen was not actually visible, but would fail. |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
Current behavior
In the initial render of the search bar through headerSearchBarOptions, it will not render. I have 4 bottom tabs and each has its own stack navigator. Search Icon does not render on initial load but would load after I switch to another tab and then current tab.
Expected behavior
The search icon should render on the first render of the screen
Reproduction
#10848
Platform
Packages
Environment
The text was updated successfully, but these errors were encountered: