Skip to content

Commit

Permalink
fix(Checkbox): fix console warning
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Oct 17, 2024
1 parent 61c6afd commit c674e97
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface CheckContextValue {

export const CheckContext = React.createContext<CheckContextValue>(null);

const Checkbox = forwardRef((_props: CheckBoxProps) => {
const Checkbox = forwardRef<HTMLDivElement, CheckBoxProps>((_props, ref) => {
const context = useContext(CheckContext);
const props = useDefaultProps(context ? context.inject(_props) : _props, checkboxDefaultProps);
const { classPrefix } = useConfig();
Expand Down Expand Up @@ -167,22 +167,20 @@ const Checkbox = forwardRef((_props: CheckBoxProps) => {
);

return (
<>
<div className={checkboxClassName} onClick={handleClick}>
{icon && renderIconNode()}
{renderCheckBoxContent()}
{/* 下边框 */}
{!borderless && (
<div className={`${classPrefixCheckBox}__border ${classPrefixCheckBox}__border--${placement}`}></div>
)}
</div>
</>
<div ref={ref} className={checkboxClassName} onClick={handleClick}>
{icon && renderIconNode()}
{renderCheckBoxContent()}
{/* 下边框 */}
{!borderless && (
<div className={`${classPrefixCheckBox}__border ${classPrefixCheckBox}__border--${placement}`}></div>
)}
</div>
);
});

Checkbox.displayName = 'Checkbox';

export default forwardRefWithStatics(
(props: TdCheckboxProps, ref: Ref<HTMLInputElement>) => <Checkbox ref={ref} {...props} />,
(props: TdCheckboxProps, ref: Ref<HTMLDivElement>) => <Checkbox ref={ref} {...props} />,
{ Group: CheckboxGroup },
);

0 comments on commit c674e97

Please sign in to comment.