0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(console): remove react warning from Switch component (#3719)

This commit is contained in:
Charles Zhao 2023-04-20 11:45:14 +08:00 committed by GitHub
parent 666c4eaaa7
commit e0649aa81a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,16 +3,16 @@ import { forwardRef } from 'react';
import * as styles from './index.module.scss';
type Props = HTMLProps<HTMLInputElement> & {
type Props = Omit<HTMLProps<HTMLInputElement>, 'value'> & {
label?: ReactNode;
};
function Switch({ label, ...rest }: Props, ref?: Ref<HTMLInputElement>) {
function Switch({ label, checked = false, ...rest }: Props, ref?: Ref<HTMLInputElement>) {
return (
<div className={styles.wrapper}>
<div className={styles.label}>{label}</div>
<label className={styles.switch}>
<input type="checkbox" {...rest} ref={ref} />
<input type="checkbox" checked={checked} {...rest} ref={ref} />
<span className={styles.slider} />
</label>
</div>