Browse Source

chore: use default parameters replace defaultProps (#5839)

main
lijianan 2 years ago
committed by GitHub
parent
commit
7f7308c85e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/components/Button.tsx
  2. 6
      src/components/MDX/ExpandableCallout.tsx

9
src/components/Button.tsx

@ -8,7 +8,7 @@ import cn from 'classnames';
interface ButtonProps {
children: React.ReactNode;
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
active: boolean;
active?: boolean;
className?: string;
style?: Record<string, string>;
}
@ -16,7 +16,7 @@ interface ButtonProps {
export function Button({
children,
onClick,
active,
active = false,
className,
style,
}: ButtonProps) {
@ -43,9 +43,4 @@ export function Button({
);
}
Button.defaultProps = {
active: false,
style: {},
};
export default Button;

6
src/components/MDX/ExpandableCallout.tsx

@ -52,7 +52,7 @@ const variantMap = {
},
};
function ExpandableCallout({children, type}: ExpandableCalloutProps) {
function ExpandableCallout({children, type = 'note'}: ExpandableCalloutProps) {
const contentRef = useRef<HTMLDivElement>(null);
const variant = variantMap[type];
@ -78,8 +78,4 @@ function ExpandableCallout({children, type}: ExpandableCalloutProps) {
);
}
ExpandableCallout.defaultProps = {
type: 'note',
};
export default ExpandableCallout;

Loading…
Cancel
Save