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 prop forwarding when as component is provided to HTML styled component #43

Merged
merged 2 commits into from
May 1, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Apr 30, 2024

Issue

Found this issue while migrating Material UI Select component. The issue can be simplified as:

const StyledDiv = styled('div')({
  classes: ['root'],
});

function Component({ TagComponent = 'span', ...props }) {
  return <TagComponent {...props} />;
}

<StyledDiv as={Component} TagComponent="button" disabled />; // <span /> instead of <button />

This is because the shouldForwardProp is not reassigned based on as prop like in Emotion.


@siriwatknp siriwatknp added the bug 🐛 Something doesn't work label Apr 30, 2024
@siriwatknp siriwatknp merged commit 791d96e into master May 1, 2024
17 checks passed
@siriwatknp siriwatknp deleted the fix/styled-forward-prop branch May 1, 2024 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants