Wondering how to correctly use a stateful component inside renderItem #732
Replies: 2 comments
-
Seems like you are triggering flashlist to re-render you tree again once it reach to a certain point on scroll..I think your issue is related to parent > children relation. If you share little bit of example, will be great to understand whats going on |
Beta Was this translation helpful? Give feedback.
-
I'm seeing that the issue is when using a sticky view. It mounts the view again, thus the component gets created again and as it is a text input, looses focus. Screen.Recording.2023-02-09.at.19.21.15.movIf I take out the Screen.Recording.2023-02-09.at.19.24.33.movI will try to extract to a project that reproduce, but it may not be that simple and probably will stop using flashlist for this type of requirements :( |
Beta Was this translation helpful? Give feedback.
-
Hi wonderful people of flash-list :)
I'm a heavy user of this framework, doing what I think complex layouts.
This time, I'm trying to render a list in which one of the items contains a element, that is a wrapper of .
I'm trying to use the same SearchBar that I've used in other place in my project, but this time using flashlist.
I'm having multiple problems related to state of the TextInput, not only on the react native side, but also of the TextInput's text.
It happens that when I scroll past the search bar, the text changes to the placeholder or vice-versa.
I attribute this issue I'm having to the renderItem of flashlist.
I've read the documentation, but I don't find any way to solve my issue.
It's not only a matter of useState, but also a matter of the text input component not preserving it text (that I don't pass as prop, but it holds internally).
Is there a way to solve this?
I've tried using renderProps, lifting state, and other stuff but couldn't solve it.
Thanks!
Depa
Screen.Recording.2023-01-14.at.18.57.00.mov
Screen.Recording.2023-01-14.at.18.58.58.mov
For reference, here's the component I've made with sectionList in which the search bar works correctly:
https://user-images.githubusercontent.com/12101394/212498994-fd45e1ab-8da4-4a7d-9a82-1ff81089c47c.mov
Beta Was this translation helpful? Give feedback.
All reactions