1
0

Created the SettingsProvider.jsx

This commit is contained in:
Mathias Wagner 2023-11-21 08:56:19 +01:00
parent c21214c65a
commit c9ff4b351e
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

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>
);
}