From 1d8d7b070e09ebd6b44905a0afc3af77a4d9364c Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Wed, 16 Nov 2022 17:05:49 +1300 Subject: [PATCH] Refresh settings for plan on focus Closes #118 --- StartPlan.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/StartPlan.tsx b/StartPlan.tsx index 0cb0863..f42759f 100644 --- a/StartPlan.tsx +++ b/StartPlan.tsx @@ -1,4 +1,4 @@ -import {RouteProp, useRoute} from '@react-navigation/native' +import {RouteProp, useFocusEffect, useRoute} from '@react-navigation/native' import {useCallback, useEffect, useMemo, useRef, useState} from 'react' import {NativeModules, TextInput, View} from 'react-native' import {FlatList} from 'react-native-gesture-handler' @@ -76,9 +76,14 @@ export default function StartPlan() { [counts, best], ) + useFocusEffect( + useCallback(() => { + settingsRepo.findOne({where: {}}).then(setSettings) + }, []), + ) + useEffect(() => { refresh().then(newCounts => select(0, newCounts)) - settingsRepo.findOne({where: {}}).then(setSettings) // eslint-disable-next-line react-hooks/exhaustive-deps }, [refresh])