Skip to content

Add support for SpecialComponents to be any ComponentType#640

Merged
wooorm merged 1 commit into
remarkjs:mainfrom
Methuselah96:special-components-component-type
Oct 21, 2021
Merged

Add support for SpecialComponents to be any ComponentType#640
wooorm merged 1 commit into
remarkjs:mainfrom
Methuselah96:special-components-component-type

Conversation

@Methuselah96

@Methuselah96 Methuselah96 commented Aug 28, 2021

Copy link
Copy Markdown
Contributor

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
Comment thread lib/ast-to-react.js

@ChristianMurphy ChristianMurphy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Methuselah96!

Comment thread lib/ast-to-react.js
@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

wooorm commented Oct 21, 2021

Copy link
Copy Markdown
Member

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.

3 participants