-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Description
I am using the Collapse component in a TypeScript project.
I am trying to set a custom trigger component for the Collapse component, using the component prop. This works if the component is a dumb one, but not if it requires props. I want a collapse trigger that is dynamically generated such that it can show a summary of the collapsed contents.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
I get the following error
62,19): No overload matches this call.
Overload 1 of 2, '(props: CollapseProps, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<...>)> | Component<...> | null', gave the following error.
Type 'Element' is not assignable to type '"object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | ... 99 more ... | undefined'.
Type 'Element' is not assignable to type 'FunctionComponent<TransitionProps>'.
Type 'Element' provides no match for the signature '(props: PropsWithChildren<TransitionProps>, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<...>)> | null'.
Overload 2 of 2, '(props: PropsWithChildren<CollapseProps>, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<...>)> | Component<...> | null', gave the following error.
Type 'Element' is not assignable to type '"object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | ... 99 more ... | undefined'.
Type 'Element' is not assignable to type 'FunctionComponent<TransitionProps>'.
Expected Behavior 🤔
I would expect that my component works as if it was JS instead of TypeScript, or some documentation for the Collapse component stating how I should typify my component. I only found a general reference to create an issue here if I were to find such a rejection though, so here I am. Also seems to be similar to issue #17699 that was fixed.
Steps to Reproduce 🕹
Here is a codesandbox showing the issue.
https://codesandbox.io/s/heuristic-lalande-plt53
Also a sandbox to show that it is not an issue in JS.
https://codesandbox.io/s/material-demo-6j9ef
Steps:
1 The error is directly visible in the sandbox.
Context 🔦
I am trying to have a dynamic Collapse trigger.
Your Environment 🌎
| Tech | Version |
|---|---|
| Material-UI | v4.9.1 |
| TypeScript | 3.8 |