Memoize action in App.tsx

This commit is contained in:
Brandon Presley 2022-11-01 16:08:02 +13:00
parent fadab1f30b
commit 139d75493e
1 changed files with 10 additions and 5 deletions

15
App.tsx
View File

@ -88,6 +88,15 @@ const App = () => {
[settings, setSettings],
)
const action = useMemo(
() => ({
label: 'Close',
onPress: () => setSnackbar(''),
color: theme.colors.primary,
}),
[theme.colors.primary],
)
return (
<PaperProvider
theme={theme}
@ -104,11 +113,7 @@ const App = () => {
duration={3000}
onDismiss={() => setSnackbar('')}
visible={!!snackbar}
action={{
label: 'Close',
onPress: () => setSnackbar(''),
color: theme.colors.primary,
}}>
action={action}>
{snackbar}
</Snackbar>
</PaperProvider>