-
Notifications
You must be signed in to change notification settings - Fork 187
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
feat: shopify/flash-list support #332
Conversation
80533c2
to
8432a87
Compare
Thanks for this, I recently briefly experimented with an implementation, but I didn't finish it because reanimated's I'm on the phone, so I can't look too deeply into the code at the moment, but did you not run into this issue? |
Or maybe it did technically seem to work, but I remember some weird errors logged. |
Yes you are, I have just seen them. I will take care and get back to you |
@andreialecu I saw the issue that you were talking about and I was able to spot why it was happening and fix it. I created one example What do you think? |
Looking great. I will take a look tomorrow. It would be great also to update the readme. The procedure is to update the template and rerun the script that re-generates the docs. Careful not to update the main readme directly because it will get overwritten by the docs script. |
Sorry I own the 2 accounts, this one is my private one 🤦 |
Could you rebase please? I just updated the repo to the latest expo. |
And regarding the README, would be nice to add a mention here in the Features block that FlashList is now supported: https://github.com/PedroBern/react-native-collapsible-tab-view/blob/main/documentation/README_TEMPLATE.md and then run |
I just tested and it looks solid. Good work! 🚀 Should be ready to merge post-rebase and once the README nit is sorted. |
01b3c29
to
c41fe8b
Compare
@andreialecu Everything done and updated. Let me know If I need to add something extra. Thanks! |
Just realized a potential problem. This makes It should be kept optional. I'll follow up with some suggestions in a bit. |
Would it be enough to just set it as optional on the package.json? |
Co-authored-by: Andrei Alecu <aandrei03@gmail.com>
src/FlashList.tsx
Outdated
@@ -0,0 +1,121 @@ | |||
import { FlashList as SPFlashList, FlashListProps } from '@shopify/flash-list' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { FlashList as SPFlashList, FlashListProps } from '@shopify/flash-list' |
useTabsContext, | ||
useUpdateScrollViewContentSize, | ||
} from './hooks' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Load FlashList dynamically or print a friendly error message
let SPFlashList, FlashListProps
try {
const flashListModule = require('@shopify/flash-list')
SPFlashList = flashListModule.FlashList
FlashListProps = flashListModule.FlashListProps
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
console.error(
'The optional dependency @shopify/flash-list is not installed. Please install it to use the FlashList component.'
)
} else {
throw error
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need also to forward the typescript types of flash-list properly here.
src/FlashList.tsx
Outdated
import { FlashList as SPFlashList, FlashListProps } from '@shopify/flash-list' | ||
import React from 'react' | ||
|
||
import { AnimatedFlashList } from './helpers' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest removing AnimatedFlashList
from ./helpers
in this case and just colocating it in the same file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Just not do the same thing twice
I left some comments of what it might look like. |
Yes, I am applying those changes and testing on the example if it works as expected. On the helpers, I will return the flatlist if the flashlist is not added |
See: #332 (comment) |
It would be best if you can test it in a project that does not have @shopify/flash-list installed. You can probably test by removing it from It's probably best to do what I mentioned here: #332 (comment) Inside of |
To pass the typescript types forward, you can likely use |
From what I see that error is printed at the root of the app, prior to opening the I mentioned in a previous comment that the dynamic require of the library should happen inside |
Oh yes you are right, I put outside the component definition. |
It appears there's this error popping up again: facebook/metro#666 That's probably fine. We give info to users about what's going on. All done, or still need to do anything else? If so I think I can merge it. 🚀 |
@andreialecu It is done, I will check this metro issue in the following days so we can remove that log. But this PR can be merged 🚀 |
I ran into that issue before and it's a metro bug, so I don't think there's anything we can do about it. |
Thanks again, and great job on this. Just released it as 6.1.0. |
Awesome! thanks for this library. I will use it right now 🚀 |
I'm running into some issues trying this in practice. The content slides underneath the header and doesn't start where it should. I noticed the We may need to do some additional patches here. 🤔 |
Oh sorry, regarding that. We need to do some patches. Maybe we can work with the ListHeader. I am experiencing on a custom scenario something similar and was able to make it work by using a ListHeader (is not the best solution but is a workaround for now since this list has a lot of different configs) |
Can you leave an example so that I can test on that one and make it work on that one? |
I noticed another more pressing glitch when the Here's a repro you can use on the diff --git a/example/src/Shared/ContactsFlashList.tsx b/example/src/Shared/ContactsFlashList.tsx
index 9379738..859dba8 100644
--- a/example/src/Shared/ContactsFlashList.tsx
+++ b/example/src/Shared/ContactsFlashList.tsx
@@ -131,9 +131,18 @@ const Contacts: React.FC<{
}> = ({ emptyContacts, nestedScrollEnabled }) => {
const [isRefreshing, startRefreshing] = useRefresh()
+ const [data, setData] = React.useState(CONTACTS)
+
+ React.useEffect(() => {
+ setInterval(() => {
+ console.log('updating contacts')
+ setData([...CONTACTS])
+ }, 1000)
+ }, [])
+
return (
<Tabs.FlashList
- data={emptyContacts ? [] : CONTACTS}
+ data={data}
keyExtractor={(_, i) => String(i)}
renderItem={renderItem}
ItemSeparatorComponent={ItemSeparator} Simulator.Screen.Recording.-.iPhone.14.-.2023-04-21.at.19.59.17.mp4 |
Have you used this property from the flatlist/flashlist:
I faced that issue and that was how i fixed it |
I had to stop away, will take a look tomorrow. When I experimented with Flashlist last time I don't remember needing that though unless for special cases like chats. Perhaps it's related to the |
oh it could be but the ref should only be set the first time 🤔 . Will check on this example i got on a private project. That was the way we fixed that same issue. |
My understanding is that Flashlist is supposed to be a drop in replacement for flatlist, where this issue doesn't exist. I also didn't notice it mentioned in the docs and couldn't find it in the issues either. That makes me think something else is going on. |
So the Flashlist is another implementation of list that uses the recyclerlist view to recycle views and make it more performant in terms of resources. FMPOV, is a normal list issue, like this issues doesn't exist as an 'issue' because there are some props to attack it ( |
@andreialecu The issue is with the require, I know how to fix. I will do that right now |
@andreialecu Opened PR for this issue: https://github.com/PedroBern/react-native-collapsible-tab-view/pull/333/files |
Fixed it in #334 and included the fix for the other issue I mentioned in #332 (comment) - it wasn't about header height but about There's still one issue remaining in #335 🤔 |
No description provided.