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

Theme component with a provider and a dynamic value #493

Open
jjjtoikka opened this issue Oct 13, 2022 · 1 comment
Open

Theme component with a provider and a dynamic value #493

jjjtoikka opened this issue Oct 13, 2022 · 1 comment

Comments

@jjjtoikka
Copy link

jjjtoikka commented Oct 13, 2022

Hello,
and thanks for a great library!

I'm trying to make a theme provider with export through react context. Problem is that the goober is using a default value in the context, so I can't update the context value after the new theme comes in. Is there any way to do that? Or am I missing something.

export const ThemeContext = createContext<ThemeType | undefined>(undefined);
export const useTheme = () => useContext(ThemeContext);

setup(React.createElement, undefined, useTheme, (props) => {
  for (const prop in props) {
    if (skipArr.includes(prop)) {
      delete props[prop];
    }
  }
});`

export const Theme = ({ children, theme }: Props) => {
  // update setup with new theme here
  return (
    <ThemeContext.Provider value={theme}>
@jjjtoikka jjjtoikka changed the title Theme component with provider and dynamic value Theme component with a provider and a dynamic value Oct 13, 2022
@jjjtoikka
Copy link
Author

Hmm, I can add a new component inside the <ThemeContext and do the setup in there.
Seems to work like that

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