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

fix: theme is not updated when calling paint() with another theme #370

Open
wa0x6e opened this issue Jun 17, 2023 · 1 comment
Open

fix: theme is not updated when calling paint() with another theme #370

wa0x6e opened this issue Jun 17, 2023 · 1 comment
Labels

Comments

@wa0x6e
Copy link
Owner

wa0x6e commented Jun 17, 2023

Calling paint({ theme: THEME }) does not update the calendar to the given theme

@wa0x6e wa0x6e added the bug label Dec 25, 2023
@yasso1am
Copy link

yasso1am commented Feb 8, 2024

In the context of React, if you are trying to dynamically adjust the theme when a user toggles dark/light mode on your page, you can do this in a non-standard-react way.

const [themeMode] = useLocalstorageState('theme', 'light');
const prevThemeMode = useRef(themeMode);
  useEffect(() => {
    if (prevThemeMode.current !== themeMode) {
      // there is no built in way to dynamically update the theme, and we don't want to destroy/repaint the entire calendar as that leads to some odd behaviors
      // @ts-ignore
      calInstance.calendarPainter.root?.attr('data-theme', themeMode);
      prevThemeMode.current = themeMode;
    }
  }, [themeMode, prevThemeMode]);

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

No branches or pull requests

2 participants