Skip to content

Commit

Permalink
add forward ref
Browse files Browse the repository at this point in the history
  • Loading branch information
softmarshmallow committed Nov 7, 2023
1 parent 2c84d43 commit 32c1a26
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/console-ui/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const bgcolormap = {
red: "red",
};

export function Button({
export const Button = React.forwardRef(function Button({
onClick,
color = "black",
width = "auto",
Expand All @@ -27,9 +27,10 @@ export function Button({
disabled?: boolean;
width?: React.CSSProperties["width"];
height?: React.CSSProperties["height"];
} & React.PropsWithChildren) {
} & React.PropsWithChildren, forwaredRef: React.Ref<HTMLButtonElement>) {
return (
<ButtonBase
ref={forwaredRef}
onClick={onClick}
disabled={disabled}
textColor={textcolormap[color]}
Expand All @@ -42,7 +43,7 @@ export function Button({
{children}
</ButtonBase>
);
}
})

const ButtonBase = styled.button<{
textColor: CSSProperties["color"];
Expand Down

0 comments on commit 32c1a26

Please sign in to comment.