Created the SettingsProvider.jsx

This commit is contained in:
2023-11-21 08:56:19 +01:00
parent c21214c65a
commit c9ff4b351e

View File

@ -0,0 +1,18 @@
import {createContext, useState} from "react";
export const SettingsContext = createContext({});
export const SettingsProvider = ({children}) => {
const [rounds, setRounds] = useState(localStorage.getItem("rounds") || 10);
const updateRounds = (newValue) => {
localStorage.setItem("rounds", newValue);
setRounds(newValue);
}
return (
<SettingsContext.Provider value={{rounds, updateRounds}}>
{children}
</SettingsContext.Provider>
);
}