reset function returned from createStitches is not in docs
jonathanlal opened this issue · comments
If you use createTheme()
inside a HOC and then change the values - the theme doesn't update:
export const ProjectProvider = ({ customTheme }: {customTheme: ConfigType.Theme}) => {
const theme = createTheme('custom-theme', customTheme);
return (
<ProjectContext.Provider value={{ something: '' }}>
<div className={theme}>
{children}
</div>
</FrostbyteContext.Provider>
);
}
function App() {
const [customTheme, setCustomTheme] = useState();
//useState functionality that changes customTheme values (like colors)
return (
<ProjectProvider customTheme={customTheme}>
...
</ProjectProvider>
);
}
Using reset()
before createTheme()
which is returned from createStitches()
does fix the issue:
export const { styled, getCssText, globalCss, createTheme, theme, reset } =
createStitches(defaultStyles);
reset(); //this makes the values update
const theme = createTheme('custom-theme', customTheme);
I only found out about reset by looking at the stitches declaration file
there's nothing in the docs about it:
Is reset being used correctly here? Should it not be described in the docs?
thanks - i love stitches btw, amazing work