-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[FlatList] Issues Rendering a TextInput within FlatList > ListHeaderComponent #13365
Comments
^^ Yup. I had to move it out. <View style={{ flex:1 }}>
<SearchBar {...searchBarProps} />
<FlatList {...flatListProps} />
</View> |
Thanks for the heads up. The problem with moving it out is that it won't scroll with the flat list though. |
Ah..Yes. That is why I also put it in the Let's hope this is fixed soon |
Ah. Yeah, definitely an issue IMO. Most other UX patterns I've seen with a search at the top of a list will scroll with the list (iOS messages, for example). My I'll keep an eye out here for updates. |
Yeah, I'm running into this case as well. Attempting to use a |
Any progress on this issue? I'm trying to convert over from sgListView since FlatList doesn't have the invisible-rows issue, but if I can't search/filter the list it's much less valuable. |
I'm actually not experiencing this anymore. I've got search bars passed into header components and they work great wil flat lists and section lists. |
@gregblass do you have a code sample? I tried upgrading to rn45 to make sure it wasn't that, still no luck. My code looks like: Render Page Header Component (there's some more, but this is the key stuff): |
I'm also getting this issue still on the latest ReactNative. |
@joncursi here's how I got it to work: Then the _headerComponent function calls the headercomponent: The key for getting the header to interact correctly (sorting and searching) was the extraData={this.state} line in the FlatList. Good luck! |
@angusmccloud thanks for posting. Tried it out in my app but wasn't successful. Anyone else get this to work? I'm about to yank my search bar out of the header and just deal with the poorer UX. |
I'm happy to report that I was able to get this to work with a rather simple fix! Using the same example as posted in the original comment, I just rendered the <FlatList
...
data={[...]}
ListHeaderComponent={
<TextInput
...
onChangeText={(value: string): void => this._onChangeText(value)}
value={this.state.query}
...
/>
}
...
/> This enables React to properly diff the |
Unfortunately, my workaround above doesn't quite work for |
@joncursi Do you know why this helps exactly? |
Still running into this issue in RN 0.51. @joncursi suggestion still seems to be the fix - instead of ListHeaderComponent={() => }, ListHeaderComponent={ } seems to work |
@connercms I believe, this is not an issue, but rather proper and expected way of passing Header component. |
just use "Arrow functions" like this sample
It works for me |
UnSubscribed
2018-01-25 18:01 GMT+03:00 dborzouei <notifications@github.com>:
… just use "Arrow functions" like this sample
`
...
renderHeader = () => {
return <TextInput
...
onChangeText={(value: string): void => this._onChangeText(value)}
value={this.state.query}
...
/>
}
...
<FlatList
...
data={[...]}
ListHeaderComponent={this. renderHeader()}
...
/>
`
It works for me
or just rendered the ListHeaderComponent directly as a React Element
instead of a render function
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#13365 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEmdC1t7a3Ij8Mhf8pcKyedAg1gCXmyks5tOJdAgaJpZM4M2aSE>
.
--
\ I I I /
( . . )
-----------oOoo----------------------
Faruk Yeşil
farukyesil@gmail.com
-----------oOoo-----------------------
|
Hi, guys any update? I am facing the same issue. If I render it as a separate component it works fine, otherwise text changes on input change. |
Thanks @angusmccloud . Adding |
I am trying to render a TextInput at the top of a FlatList so that the user can search / filter the list of data.
Every time the
value
prop given toTextInput
changes, the keyboard dismisses rather than staying active and allowing the user to type. It looks as though the entireTextInput
component is unmounted and re-mounted, forcing this odd behavior.I've used this pattern on
ListView
'srenderHeader
with great success. Would like to see it working onFlatList
as well!The text was updated successfully, but these errors were encountered: