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

Button Icon 不会更新 #49

Closed
ZeroCodeLin opened this issue Oct 26, 2021 · 1 comment
Closed

Button Icon 不会更新 #49

ZeroCodeLin opened this issue Oct 26, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@ZeroCodeLin
Copy link

Which Component 出现bug的组件

  • Button

semi-ui version

  • latest

Expected result 期望的结果是什么

  • type改变 ,按钮对应的Icon也要改变

Actual result 实际的结果是什么

  • 第一次会变,后面就不会变了

Steps to reproduce 复现步骤

  • 1

Reproducible code 复现代码

const SwitchMode = props => {
    const [type, setType] = useState<string>('drak')

    const switchMode = () => {
        const body = document.body;
        if (body.hasAttribute('theme-mode')) {
            setType('light')
            body.removeAttribute('theme-mode');
        } else {
            setType('dark')
            body.setAttribute('theme-mode', 'dark');
        }
    }

    return (
        <div>
            {type}
            <Button
                theme="borderless"
                icon={type === 'drak' ? <IconSun size="large" /> : <IconMoon size="large" />}
                style={{
                    color: 'var(--semi-color-text-2)',
                    marginRight: '12px',
                }}
                onClick={switchMode}
            />
        </div>
    );
}

Additional information 补充说明

  • 遇到这个bug的业务场景、上下文、或者你的需求场景
@ZeroCodeLin ZeroCodeLin added the bug Something isn't working label Oct 26, 2021
@ZeroCodeLin
Copy link
Author

拼写错误

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant