-
Notifications
You must be signed in to change notification settings - Fork 292
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
First sticky header is not updated when data is changed #814
Comments
We can reproduce the same behaviour. |
Any work around to fix this issue? |
@naqvitalha any chance to provide at least temporary workaround? |
have same issue. P.S.: If you add an element to array (even if it's not rendered), and add his index to sticky headers, it will update your first sticky header. |
This still happens in version 1.4.3 I've currently worked around it by updating the |
A better way to fix this rather than updating the const renderItem = ({ item }) => {
if(item === "FAKE_HEADER") return null;
if (typeof item === "string") {
return <MyChatSectionHeader title={item} />;
}
return <MyChatItem
item={item}
navigation={navigation}
/>
};
const stickyHeaderIndices = myChats
.map((item, index) => (typeof item === "string" ? index+1 : null))
.filter(index => index !== null);
<FlashList
data={["FAKE_HEADER", ...myChats]}
renderItem={renderItem}
keyExtractor={item => typeof item === "string" ? item : item._id}
onEndReached={loadMoreChatsHandler}
onEndReachedThreshold={0.05}
ListFooterComponent={<LoadingMoreFooter isLoadingMore={isLoadingMore} />}
stickyHeaderIndices={stickyHeaderIndices}
getItemType={item => typeof item === "string" ? "sectionHeader" : "row"}
estimatedItemSize={70}
/> However, there will be a slight shake if you scroll up the list since the fake header's indices is counted |
I just found a ever better solution without even slight shaking: const [stickyIndices, setStickyIndices] = useState([]);
useEffect(() => {
const getStickyIndices = (number=0) => {
return myChats
.map((item, index) => (typeof item === "string" ? index+number : null))
.filter(index => index !== null);
}
setStickyIndices(getStickyIndices(1));
setTimeout(() => {
setStickyIndices(getStickyIndices(0));
}, 100);
}, [myChats.length]);
<FlashList
data={myChats}
renderItem={renderItem}
keyExtractor={item => typeof item === "string" ? item : item._id}
onEndReached={loadMoreChatsHandler}
onEndReachedThreshold={0.05}
ListFooterComponent={<LoadingMoreFooter isLoadingMore={isLoadingMore} />}
stickyHeaderIndices={stickyIndices}
getItemType={item => typeof item === "string" ? "sectionHeader" : "row"}
estimatedItemSize={70}
/> After all, those are temporary solutions, hope someone could make a PR for this |
+1 |
1 similar comment
+1 |
this issue is still exist |
I have the same problem. First sticky header is not updated when the data changes. |
+1 |
2 similar comments
+1 |
+1 |
Yeah, honestly seeing a lot of bugs tied directly to |
+1 |
1 similar comment
+1 |
I can't believe how much time I wasted before finding this bug report. 🥲 |
+1 |
As a simpler workaround, use const stickyHeaderIndices = new Array(...); This will force the FlashList to detect the change. No need for edit: posted this solution a little too prematurely. This will re-render the first item, but the item is no longer sticky. Sigh. |
…nging stickyHeaderIndices updated
…nging stickyHeaderIndices updated
…nging stickyHeaderIndices updated
…nging stickyHeaderIndices updated
Does this have an official fix in the works? |
Any updates on that ? 🥺 |
What is the status of this issue? I see that the PR is ready. When do you plan to release it? |
…tickyHeaderIndices updated (#1267)
your solution works beautifully
|
I see that PR #1267 has been merged into the main branch, and that’s awesome! :) Thanks for the response. |
Still facing this issue in Android, Is there any update on this to be released? |
@DTupalov @dkumar-carfax have you both tested on version 1.7.2? |
This seems fixed on 1.7.2 for me |
This is not fixed in 1.7.2. edit: additional info: the header is updated in case it's not in the "sticky mode", but if it is, it doesn't update. See attached video clip. ScreenRecording_12-03-2024.15-58-48_1.mov |
Facing the same issue, has anyone had any solutions? |
I have the same behavior still. |
Current behavior
When we update data of list with sticky headers, the first one(that is currently sticky) is not updated, while the rest is updated.
Expected behavior
Items are updated when data is changed
To Reproduce
https://snack.expo.dev/@todorone/flashlist-sticky-headers-bug
Platform:
Environment
1.3.1
The text was updated successfully, but these errors were encountered: