Skip to content

Commit

Permalink
W/features (#4)
Browse files Browse the repository at this point in the history
* Implement react context

* Fix code smell
  • Loading branch information
wazeerc authored Aug 9, 2024
1 parent 07c7988 commit 4b0e381
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const LIVES: number = 3;
const FlagsContext = createContext(
{
sessionCountry: countryNamesAndCode[Math.floor(Math.random() * countryNamesAndCode.length)],
lives: 3,
lives: LIVES,
selection: null,
isSelectionCorrect: false,
handleNextFlag: () => {},
Expand All @@ -24,15 +24,15 @@ export const FlagsProvider = ({ children }: IFlagsContextProps) => {
const [sessionCountry, setSessionCountry] = useState(
countryNamesAndCode[Math.floor(Math.random() * countryNamesAndCode.length)]
);
const [lives, setLives] = useState(3);
const [lives, setLives] = useState(LIVES);
const [selection, setSelection] = useState(null);
const [isSelectionCorrect, setIsSelectionCorrect] = useState(false);

const handleNextFlag = () => {
setSessionCountry(
countryNamesAndCode[Math.floor(Math.random() * countryNamesAndCode.length)]
);
setLives(3);
setLives(LIVES);
setSelection(null);
setIsSelectionCorrect(false);
};
Expand Down

0 comments on commit 4b0e381

Please sign in to comment.