From 86ca76194dc1fdc77e99a29713c8ee1fb17d2539 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 10 Jun 2021 14:11:05 -0300 Subject: [PATCH] [FIX] RoomItem's long press crashing the app if prop is missing (#3199) * Check onLongPress prop * Add Touch stories --- .../__snapshots__/Storyshots.test.js.snap | 398 ++++++++++++++++++ app/presentation/RoomItem/index.js | 4 +- storybook/stories/RoomItem.js | 3 + 3 files changed, 404 insertions(+), 1 deletion(-) diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 52fa5d01d..3e3106d94 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -59100,6 +59100,404 @@ exports[`Storyshots Room Item Tag 1`] = ` `; +exports[`Storyshots Room Item Touch 1`] = ` + + + + + + + + +  + + + Read + + + + + + + +  + + + Favorite + + + + +  + + + Hide + + + + + + + + + + + + + +  + + + rocket.cat + + + + + + + + + +`; + exports[`Storyshots Room Item Type 1`] = ` { const { item, onLongPress } = this.props; - return onLongPress(item); + if (onLongPress) { + return onLongPress(item); + } } render() { diff --git a/storybook/stories/RoomItem.js b/storybook/stories/RoomItem.js index 025fbf7f5..c13eaa4d2 100644 --- a/storybook/stories/RoomItem.js +++ b/storybook/stories/RoomItem.js @@ -44,6 +44,9 @@ stories.add('Basic', () => ( )); +stories.add('Touch', () => ( + alert('on press')} onLongPress={() => alert('on long press')} /> +)); stories.add('User', () => ( <>