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

Types: MdxComponents types were not working for me #9

Open
wcastand opened this issue Jun 12, 2023 · 0 comments
Open

Types: MdxComponents types were not working for me #9

wcastand opened this issue Jun 12, 2023 · 0 comments

Comments

@wcastand
Copy link

wcastand commented Jun 12, 2023

Hi, not sure if it's something that needs to change in the repo or not but i had to change the types in the package for the MDXComponents to :

export declare function MDXComponents({ children, components, ...props }: {
    children?: any;
    components?: Partial<Record<keyof ReturnType<typeof getBaseElements>, (props: any) => JSX.Element>>;
} & Partial<Elements>): JSX.Element;

the current types expect components to be Record<string, React.ReactNode> but when i was passing something like :

<MDXComponents components={{
  h1: (props) => <Text {...props} />
}} />

I was getting an error on typescript saying (props:any) => Elements is not compatible with ReactNode. I tried to use our custom Text component but also with the one from react-native and was still getting the error.

If you think the change is valid, let me know and i can submit the Pr or let you do it if you prefer :)

also not sure for a generic version of it and a compatible one with web but for the UL component i'm doing this and it seems to be working for us (Box is a View):

const UL = ({ children }: PropsWithChildren<{}>) => {
	return (
		<Box>
			{Children.map(children, (child) => (
				<Text variant="body" mb="xsmall">
					 {child}
				</Text>
			))}
		</Box>
	)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant