Skip to content

Commit

Permalink
fix regular functions not being rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
dorkyboi committed Apr 23, 2021
1 parent 05f5229 commit e5fc6d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions components/Swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {useWindowDimensions, FlatList, ScrollView, Text, TouchableOpacity, View}
import StaticPills from "./StaticPills";
import {usePrevious} from "../helpers/usePrevious";

const isJSX = element => typeof element?.type === 'object';
const isMemo = element => typeof element?.type === 'function';
const isJSX = element => typeof element !== 'function' && typeof element?.type === 'object';
const isMemo = element => typeof element !== 'function' && typeof element?.type === 'function';

export default function Swiper({style, data, isStaticPills, initialScrollIndex, ...rest}) {
const width = useWindowDimensions().width;
Expand Down Expand Up @@ -50,8 +50,8 @@ export default function Swiper({style, data, isStaticPills, initialScrollIndex,
});
const renderItem = ({item: {component: Component, props = {}}, index}) => (
<View style={{width}}>
{typeof Component !== 'function' && isJSX(Component) && Component}
{typeof Component === 'function' || (typeof Component !== 'function' && isMemo(Component)) && <Component {...props} index={index}/>}
{isJSX(Component) && Component}
{(typeof Component === 'function' || isMemo(Component)) && <Component {...props} index={index}/>}
</View>
);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-screens-swiper",
"version": "1.1.2",
"version": "1.1.3",
"description": "This lib. provide swiper view functionality with tab navigation on the top.",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit e5fc6d7

Please sign in to comment.