From 139d75493e1d3dffb002130ad6b5d0ce149024d1 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Tue, 1 Nov 2022 16:08:02 +1300 Subject: [PATCH] Memoize action in App.tsx --- App.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/App.tsx b/App.tsx index 889c03b..dade68d 100644 --- a/App.tsx +++ b/App.tsx @@ -88,6 +88,15 @@ const App = () => { [settings, setSettings], ) + const action = useMemo( + () => ({ + label: 'Close', + onPress: () => setSnackbar(''), + color: theme.colors.primary, + }), + [theme.colors.primary], + ) + return ( { duration={3000} onDismiss={() => setSnackbar('')} visible={!!snackbar} - action={{ - label: 'Close', - onPress: () => setSnackbar(''), - color: theme.colors.primary, - }}> + action={action}> {snackbar}