Fix: reset checklist when changing language

This commit is contained in:
Richard Wong 2024-08-20 13:35:13 +09:00
parent d7fdf2df50
commit 965d985251
Signed by: richard
GPG Key ID: 72948FBB6D359A6D
1 changed files with 10 additions and 17 deletions

View File

@ -104,6 +104,10 @@ function Page() {
// function hook to change language // function hook to change language
// updates both i18n language and also the VerseData state variable // updates both i18n language and also the VerseData state variable
const changeLanguage = (lng) => { const changeLanguage = (lng) => {
// reset selection list
setChecked([]);
setExpanded([]);
// i18n.changeLanguage is async, so we should wait until its done to avoid // i18n.changeLanguage is async, so we should wait until its done to avoid
// race conditions // race conditions
// console.log("change language"); // 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 // initialize state variable testCount
// purpose: to set number of verses to test // purpose: to set number of verses to test
const [testCount, setTestCount] = useState(20) const [testCount, setTestCount] = useState(20)
@ -252,7 +240,12 @@ function Page() {
// loading component for suspense fallback // loading component for suspense fallback
const Loader = () => ( const Loader = () => (
<div className="App"> <div className="App">
<img src={logo} className="App-logo" alt="logo" /> <img
src={logo}
className="App-logo"
alt="logo"
style={{ width: '20vw', height: 'auto' }}
/>
<div>loading...</div> <div>loading...</div>
</div> </div>
); );