Skip to content
Discussion options

You must be logged in to vote

solved it

const useThemeListener = () => {
    const { isDarkTheme } = useColorMode();
    const html = document.documentElement;
    const observer = new MutationObserver((mutation) => {
        const className = (mutation[0].target as any).className as string;
        if (
            (className.includes('tw-dark') && !isDarkTheme) ||
            (!className.includes('tw-dark') && isDarkTheme)
        ) {
            changeElement(isDarkTheme);
        }
    });
    const changeElement = useCallback((isDark: boolean) => {
        if (isDark) {
            html.classList.add('tw-dark');
            document.body.setAttribute('arco-theme', 'dark');
        } else {
            html.classList

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by pincman
Comment options

You must be logged in to vote
1 reply
@dxiongya
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants