Is there a way to have fixed and permeant top-titlebar(I think it's called as Header?) for react native?
Almost like a status bar, it's always there. But it needs to be at the top (even before the 'header' from the react-navigation)
My plan was to put a global-search input there, so anywhere in the app you can search(Search content not affected by the screen that's presented at the moment. Pure global search always available.)
Is there a way to do this? I'm currently working with expo and react-navigation.
--- Edit
I add the screenshot of wireframe that shows what I meant. You'll notice that the Search bar stays at the top regardless the screen you are on. It's a global search bar.
-- Edit
I think I need to say this clearly. I'm trying to do this with ReactNavigation. I think I need to play with 'createAppContainer', or any create navigator function like 'createDrawerNavigator' and figure out a way to put in the fixed header with the navigate-able screens.
Building the StickyHeader hook isSticky && setIsSticky(true); } else { isSticky && setIsSticky(false); } }, [isSticky] ); useEffect(() => { const handleScroll = () => { toggleSticky(tableRef. current. getBoundingClientRect()); }; window. addEventListener("scroll", handleScroll); return () => { window.
A final aspect to consider is whether the sticky header truly needed. Ultimately, by using a sticky header you give away some screen real estate on every single page of your site. And, if the sticky header is not helpful to your users, any other optimizations you make to its design are moot.
The react native's component FlastList has a property ListHeaderComponent
for rendering a header and another one to stick it stickyHeaderIndices
. This is exactly what you need.
In the ListHeaderComponent
you will render your search field and with stickyHeaderIndices={[0]}
will set it as a sticky header:
<FlatList
data={ this.state.data }
renderItem={({item}) => this.renderItem(item)}
ListHeaderComponent={this.renderHeader}
stickyHeaderIndices={[0]}
/>
Check out the working example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With