From 7f7308c85e39f27b7b51d2542df9dd4f1dc29371 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Wed, 29 Mar 2023 20:58:36 +0800 Subject: [PATCH] chore: use default parameters replace defaultProps (#5839) --- src/components/Button.tsx | 9 ++------- src/components/MDX/ExpandableCallout.tsx | 6 +----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 1dc5b4b8..65c0151b 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -8,7 +8,7 @@ import cn from 'classnames'; interface ButtonProps { children: React.ReactNode; onClick?: (event: React.MouseEvent) => void; - active: boolean; + active?: boolean; className?: string; style?: Record; } @@ -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; diff --git a/src/components/MDX/ExpandableCallout.tsx b/src/components/MDX/ExpandableCallout.tsx index 372c070d..1fb1ea0c 100644 --- a/src/components/MDX/ExpandableCallout.tsx +++ b/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(null); const variant = variantMap[type]; @@ -78,8 +78,4 @@ function ExpandableCallout({children, type}: ExpandableCalloutProps) { ); } -ExpandableCallout.defaultProps = { - type: 'note', -}; - export default ExpandableCallout;