react-native-screens-swiper
Version:
This lib. provide swiper view functionality with tab navigation on the top.
16 lines (13 loc) • 634 B
JSX
import React from 'react';
import {View, useWindowDimensions} from 'react-native';
export default function ItemComponent({Component, index, ...rest}) {
const width = useWindowDimensions().width;
const isJSX = element => typeof element !== 'function' && typeof element?.type === 'object';
const isMemo = element => typeof element !== 'function' && typeof element?.type === 'function';
return(
<View style={{width}}>
{isJSX(Component) && Component}
{(typeof Component === 'function' || isMemo(Component)) && <Component {...rest} index={index}/>}
</View>
);
}