Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset function returned from createStitches is not in docs #1147

Open
jonathanlal opened this issue Mar 8, 2023 · 0 comments
Open

reset function returned from createStitches is not in docs #1147

jonathanlal opened this issue Mar 8, 2023 · 0 comments

Comments

@jonathanlal
Copy link

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
image

there's nothing in the docs about it:
image

Is reset being used correctly here? Should it not be described in the docs?

thanks - i love stitches btw, amazing work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant