PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
827 stars 160 forks source link

Using Custom Components #290

Open ahmetkuslular opened 1 year ago

ahmetkuslular commented 1 year ago

Feature request

Is it possible to set up a structure where we can pass custom components instead of adding all components? New components such as FlatGrid and FlashList are coming out. I want to use these components with this package.

Note: I simply tried and succeeded. But it has to be done in a controlled way.

FlatGrid: https://github.com/saleel/react-native-super-grid FlashList: https://github.com/Shopify/flash-list

Example:

<Tabs.Custom
  component={FlashList}
   ...
/> 
baronha commented 1 year ago

same +1

linleiqin commented 1 year ago

same +1

ursnj commented 1 year ago

Same +1

ricardopacheco commented 1 year ago

Any news? +1

pfcodes commented 1 year ago

Bump

edit: @ahmetkuslular you said you tried and succeeded. how'd you do it?

ahmetkuslular commented 1 year ago

I just made it for testing purposes. I checked if it works or not. I have not done detailed testing.

  1. Copy FlatList.tsx -> CustomList.tsx

CustomList.tsx

const CustomListMemo = React.memo(
    React.forwardRef<RNFlatList, React.PropsWithChildren<FlatListProps<unknown>>>(
        ({component, ...props}, passRef) => {
            const AnimatedCustomList = Animated.createAnimatedComponent(component)
            return <AnimatedCustomList ref={passRef} {...props} />
        }
    )
)

//the rest are the same. Here, component-specific props need to be managed separately.
...

Example.tsx

import { FlatGrid } from 'react-native-super-grid';

<Tabs.CustomList
      component={FlatGrid}
      ...props
/>

Bump

edit: @ahmetkuslular you said you tried and succeeded. how'd you do it?