From 965d985251e34f7c0bbeeec62c575b48fac44f14 Mon Sep 17 00:00:00 2001 From: Richard Wong Date: Tue, 20 Aug 2024 13:35:13 +0900 Subject: [PATCH] Fix: reset checklist when changing language --- src/VerseSampler.jsx | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/VerseSampler.jsx b/src/VerseSampler.jsx index b5b8372..56956a3 100644 --- a/src/VerseSampler.jsx +++ b/src/VerseSampler.jsx @@ -104,6 +104,10 @@ function Page() { // function hook to change language // updates both i18n language and also the VerseData state variable const changeLanguage = (lng) => { + // reset selection list + setChecked([]); + setExpanded([]); + // i18n.changeLanguage is async, so we should wait until its done to avoid // race conditions // console.log("change language"); @@ -113,22 +117,6 @@ function Page() { }; - - // // create checklist array for pack selection - // const packList = Object.keys(VerseData); - // // return a list of packObj's - // // 1. packObj.pack for the pack name - // // 2. packObj.include for whether to include the pack - // const packObjList = packList.map((element) => { - // // create object for each element in VerseData key list - // const packObj = new Object(); - // packObj.pack = element; - // packObj.include = false; - // return packObj - // } - // ) - // const [packs, setPacks] = useState(packObjList) - // initialize state variable testCount // purpose: to set number of verses to test const [testCount, setTestCount] = useState(20) @@ -252,7 +240,12 @@ function Page() { // loading component for suspense fallback const Loader = () => (
- logo + logo
loading...
);