Skip to content

Commit ed7ce8b

Browse files
committed
Remove dead nulls.
1 parent 37a8d05 commit ed7ce8b

File tree

2 files changed

+48
-103
lines changed

2 files changed

+48
-103
lines changed

components/createHeaderBodyFooterComponent/index.tsx

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,54 @@ export const createHeaderBodyFooterComponent = (
5757
},
5858
});
5959

60-
return ({ header, body, footer }) => (
61-
<View
62-
style={
63-
!header && !footer && !body
64-
? globalStyles.emptyWrappingView
65-
: header && footer && !body
66-
? globalStyles.wrappingViewWithoutBody
67-
: footer && !body && !header
68-
? globalStyles.wrappingViewWithOnlyFooter
69-
: globalStyles.wrappingView
70-
}
71-
>
72-
{header ? (
60+
return ({ header, body, footer }) => {
61+
const children = [];
62+
63+
if (header) {
64+
children.push(
7365
<View
7466
{...(body && headerBodySpacing
7567
? { style: localStyles.headerView }
7668
: {})}
7769
>
7870
{header}
7971
</View>
80-
) : null}
81-
{body ? <View style={globalStyles.bodyView}>{body}</View> : null}
82-
{footer ? (
72+
);
73+
}
74+
75+
if (body) {
76+
children.push(<View style={globalStyles.bodyView}>{body}</View>);
77+
}
78+
79+
if (footer) {
80+
children.push(
8381
<View
8482
{...(body && bodyFooterSpacing
8583
? { style: localStyles.footerView }
8684
: {})}
8785
>
8886
{footer}
8987
</View>
90-
) : null}
91-
</View>
92-
);
88+
);
89+
}
90+
91+
return (
92+
<View
93+
style={
94+
!header && !footer && !body
95+
? globalStyles.emptyWrappingView
96+
: header && footer && !body
97+
? globalStyles.wrappingViewWithoutBody
98+
: footer && !body && !header
99+
? globalStyles.wrappingViewWithOnlyFooter
100+
: globalStyles.wrappingView
101+
}
102+
{...(children.length === 0
103+
? {}
104+
: children.length === 1
105+
? { children: children[0] }
106+
: { children })}
107+
/>
108+
);
109+
};
93110
};

0 commit comments

Comments
 (0)