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 { interface ButtonProps {
children: React.ReactNode; children: React.ReactNode;
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
active: boolean; active?: boolean;
className?: string; className?: string;
style?: Record<string, string>; style?: Record<string, string>;
} }
@ -16,7 +16,7 @@ interface ButtonProps {
export function Button({ export function Button({
children, children,
onClick, onClick,
active, active = false,
className, className,
style, style,
}: ButtonProps) { }: ButtonProps) {
@ -43,9 +43,4 @@ export function Button({
); );
} }
Button.defaultProps = {
active: false,
style: {},
};
export default Button; 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 contentRef = useRef<HTMLDivElement>(null);
const variant = variantMap[type]; const variant = variantMap[type];
@ -78,8 +78,4 @@ function ExpandableCallout({children, type}: ExpandableCalloutProps) {
); );
} }
ExpandableCallout.defaultProps = {
type: 'note',
};
export default ExpandableCallout; export default ExpandableCallout;

Loading…
Cancel
Save