I have a few nested Context Providers in my app that look like this
export const LangContext = React.createContext("javascript");
export const FontContext = React.createContext("mono-space");
export const FontSizeContext = React.createContext("16px");
const Store = ({ children }) => {
const [lang, setLang] = useState("javascript");
const [font, setFont] = useState("mono-space");
const [fontSize, setFontSize] = useState("16px");
return (
<LangContext.Provider value={[lang, setLang]}>
<FontContext.Provider value={[font, setFont]}>
<FontSizeContext.Provider value={[fontSize, setFontSize]}>
{children}
</FontSizeContext.Provider>
</FontContext.Provider>
</LangContext.Provider>
);
};
I'm sure this is a bad practice but I'm not sure how to handle this. I want to be able to create a single context provider for all the contexts.