From 4b0e3812e9572de44ace68d390a2eee3e018f80c Mon Sep 17 00:00:00 2001 From: Wazeer <58399263+wazeerc@users.noreply.github.com> Date: Fri, 9 Aug 2024 20:43:35 +0400 Subject: [PATCH] W/features (#4) * Implement react context * Fix code smell --- src/Context.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Context.tsx b/src/Context.tsx index 6d0d1f3..4e9ecb3 100644 --- a/src/Context.tsx +++ b/src/Context.tsx @@ -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: () => {}, @@ -24,7 +24,7 @@ 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); @@ -32,7 +32,7 @@ export const FlagsProvider = ({ children }: IFlagsContextProps) => { setSessionCountry( countryNamesAndCode[Math.floor(Math.random() * countryNamesAndCode.length)] ); - setLives(3); + setLives(LIVES); setSelection(null); setIsSelectionCorrect(false); };