Created the SettingsProvider.jsx
This commit is contained in:
parent
c21214c65a
commit
c9ff4b351e
18
client/src/common/contexts/SettingsProvider.jsx
Normal file
18
client/src/common/contexts/SettingsProvider.jsx
Normal 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>
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user