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

Add support for SpecialComponents to be any ComponentType #640

Merged

Conversation

Methuselah96
Copy link
Contributor

@Methuselah96 Methuselah96 commented Aug 28, 2021

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

Changes the SpecialComponents to allow them to be any ComponentType (not just a function component).

My use case is adding styles to the components with Material-UI. Here's an example of what I'm trying to do:

export default function Markdown(props: ReactMarkdownOptions) {
  return (
    <ReactMarkdown
      components={{
        li: withStyles(styles)(
          ({
            classes,
            color,
            node,
            ref,
            ...props
          }: JSX.IntrinsicElements['li'] &
            ReactMarkdownProps & {
              checked: boolean | null;
              index: number;
              ordered: boolean;
            } & WithStyles<typeof styles>) => (
            <li className={classes.listItem}>
              <Typography paragraph component="span" {...props} />
            </li>
          ),
        ),
      }}
      {...props}
    />
  );
}

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Aug 28, 2021
Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

Thanks @Methuselah96!

lib/ast-to-react.js Show resolved Hide resolved
@ChristianMurphy ChristianMurphy added the ☂️ area/types This affects typings label Sep 10, 2021
@wooorm wooorm changed the title Allow SpecialComponents to be any ComponentType Add support for SpecialComponents to be any ComponentType Oct 21, 2021
@wooorm wooorm merged commit 7b8a829 into remarkjs:main Oct 21, 2021
@wooorm wooorm added the 💪 phase/solved Post is done label Oct 21, 2021
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Oct 21, 2021
@Methuselah96 Methuselah96 deleted the special-components-component-type branch October 21, 2021 13:58
@wooorm
Copy link
Member

wooorm commented Oct 21, 2021

Sorry, forgot about this PR. Released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☂️ area/types This affects typings 💪 phase/solved Post is done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants