From a9000898f35f269f74cb1392db74c5cb69b7fe4c Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Fri, 30 Dec 2022 19:49:54 +1300 Subject: [PATCH] Replace children with title for Switch Apparently, the children prop makes React.memo not work any more. I read about it in https://stackoverflow.com/questions/53074551/when-should-you-not-use-react-memo --- EditPlan.tsx | 12 ++++++------ Routes.tsx | 26 ++++++++++---------------- SettingsPage.tsx | 6 +++--- Switch.tsx | 6 +++--- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/EditPlan.tsx b/EditPlan.tsx index 4e69281..45dfc2b 100644 --- a/EditPlan.tsx +++ b/EditPlan.tsx @@ -80,9 +80,9 @@ export default function EditPlan() { toggleDay(value, day)} - value={days.includes(day)}> - {day} - + value={days.includes(day)} + title={day} + /> ))} Workouts {names.length === 0 ? ( @@ -94,9 +94,9 @@ export default function EditPlan() { toggleWorkout(value, name)} - value={workouts.includes(name)}> - {name} - + value={workouts.includes(name)} + title={name} + /> )) )} diff --git a/Routes.tsx b/Routes.tsx index c524b7a..eae208b 100644 --- a/Routes.tsx +++ b/Routes.tsx @@ -36,22 +36,16 @@ export default function Routes() { swipeEdgeWidth: 1000, headerShown: false, }}> - {} - {routes - .filter(route => { - if (Platform.OS === 'ios' && route.name === 'Timer') return false - return true - }) - .map(route => ( - , - }} - /> - ))} + {routes.map(route => ( + , + }} + /> + ))} ) } diff --git a/SettingsPage.tsx b/SettingsPage.tsx index 10f2dda..abef19e 100644 --- a/SettingsPage.tsx +++ b/SettingsPage.tsx @@ -153,9 +153,9 @@ export default function SettingsPage() { changeBoolean(item.key, value)}> - {item.name} - + onChange={value => changeBoolean(item.key, value)} + title={item.name} + /> ), [changeBoolean], ) diff --git a/Switch.tsx b/Switch.tsx index 83ba25e..bf27162 100644 --- a/Switch.tsx +++ b/Switch.tsx @@ -6,11 +6,11 @@ import {MARGIN} from './constants' function Switch({ value, onChange, - children, + title, }: { value?: boolean onChange: (value: boolean) => void - children: string + title: string }) { const {colors} = useTheme() @@ -30,7 +30,7 @@ function Switch({ onValueChange={onChange} trackColor={{true: colors.primary + '80', false: colors.disabled}} /> - {children} + {title} ) }