Skip to content

Commit

Permalink
fix loading problem of challange winner list
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasWillibaldWeber committed Sep 4, 2023
1 parent e062346 commit f72ae13
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions proggame-react/src/components/AppOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { saveName, loadNames } from '../utils/NameStorage';

export default function AppOverlay({state, setState, setOut, tasks, setTasks, initVal, setInitVal, name, setName}) {

const [names, setNames] = useState(undefined);
const [names, setNames] = useState([]);

const challange = `Challenge! ${name} wants to solve five random tasks in a row!`;
const congratulations = `Congratulations! ${name} has solved five random tasks in a row!`;
Expand All @@ -28,10 +28,10 @@ export default function AppOverlay({state, setState, setOut, tasks, setTasks, in
});
}

if (names === undefined && state === -1) {
if (state === -1) {
loadNames().then( n => {
setNames(n);
}).catch( () => setNames([]));
}).catch( (e) => console.log(e));
}

return (state === -3 || state === -1 || state === 5) ? (
Expand Down

0 comments on commit f72ae13

Please sign in to comment.