Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: React dom failure when passing unknown props to child component #49

Merged
merged 3 commits into from
Apr 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { ButtonMenuItemProps } from "./types";

interface InactiveButtonProps extends BaseButtonProps {
forwardedAs: BaseButtonProps["as"];
colorKey: "primary" | "textSubtle";
}

const InactiveButton: PolymorphicComponent<InactiveButtonProps, "button"> = styled(Button)<InactiveButtonProps>`
background-color: transparent;
color: ${({ theme, colorKey }) => theme.colors[colorKey]};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial solution here is wrong imo. If you want to clean this, a better solution is to remove the colorkey attribute and compute the color based on the variant attribute

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@memoyil

@RabbitDoge is right in it is not an ideal solution. Do you mind fixing it? No worries if you can't, I will get to it.

Copy link
Contributor Author

@memoyil memoyil Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hachiojidev I will try to fix it :) if I could not I will ask your help. Thanks 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hachiojidev can you review it again?

color: ${({ theme, variant }) => (variant === variants.PRIMARY ? theme.colors.primary : theme.colors.textSubtle)};
&:hover:not(:disabled):not(:active) {
background-color: transparent;
}
Expand All @@ -24,14 +23,7 @@ const ButtonMenuItem: PolymorphicComponent<ButtonMenuItemProps, "button"> = ({
...props
}: ButtonMenuItemProps) => {
if (!isActive) {
return (
<InactiveButton
forwardedAs={as}
variant="tertiary"
colorKey={variant === variants.PRIMARY ? "primary" : "textSubtle"}
{...props}
/>
);
return <InactiveButton forwardedAs={as} variant="tertiary" {...props} />;
}

return <Button as={as} variant={variant} {...props} />;
Expand Down