Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

safely return empty element if item is null

ammarahm-ede13ec8991292
diff --git a/apps/mobile/src/components/SelectionWrapper/actionstrip.js b/apps/mobile/src/components/SelectionWrapper/actionstrip.js
index 9a7033577..98b7a8f60 100644
--- a/apps/mobile/src/components/SelectionWrapper/actionstrip.js
+++ b/apps/mobile/src/components/SelectionWrapper/actionstrip.js
@@ -269,7 +269,7 @@ export const ActionStrip = ({note, setActionStrip}) => {
/>
{actions.map(
item =>
- item.visible && (
+ item.visible ? (
<View
key={item.icon}
style={{
@@ -292,7 +292,7 @@ export const ActionStrip = ({note, setActionStrip}) => {
size={width / 2.8 / actions.length}
/>
</View>
- ),
+ ) : null,
)}
</Animated.View>
);
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index a11252b58..8923893b8 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -23,6 +23,7 @@ let renderItems = {
};
const RenderItem = ({item, index}) => {
+ if (!item) return <View/>
const Item = renderItems[item.itemType || item.type] || <View/>
return (
diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js
index ac322ca9f..d4391d25a 100644
--- a/apps/mobile/src/views/Trash/index.js
+++ b/apps/mobile/src/views/Trash/index.js
@@ -131,13 +131,13 @@ export const Trash = ({route, navigation}) => {
placeholderText="Deleted notes & notebooks appear here."
/>
- {trash && trash.length !== 0 && (
+ {trash && trash.length !== 0 ? (
<ContainerBottomButton
title="Clear all trash"
onPress={_onPressBottomButton}
shouldShow={true}
/>
- )}
+ ) : null}
</>
);
};