PanelBarUtils mapItemsToComponents not compatible with @types/react v18

1 Answer 65 Views
PanelBar
David
Top achievements
Rank 1
Iron
Iron
Veteran
David asked on 10 Oct 2022, 10:58 AM | edited on 10 Oct 2022, 10:58 AM

I am in the process of upgrading React to v18 and KendoReact to v5 latest versions. The only issue I am having is with the PanelBar. We were using PanelBarUtils.mapItemsToComponents(items) and passing this to the children prop of the PanelBar. The current Kendo documentation says this is still valid, however it now results in a TypeScript error:

Type 'PanelBarItem[]' is not assignable to type 'ReactNode'.
  Type 'PanelBarItem[]' is not assignable to type 'ReactFragment'.
    The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
      Type 'IteratorResult<PanelBarItem, any>' is not assignable to type 'IteratorResult<ReactNode, any>'.
        Type 'IteratorYieldResult<PanelBarItem>' is not assignable to type 'IteratorResult<ReactNode, any>'.
          Type 'IteratorYieldResult<PanelBarItem>' is not assignable to type 'IteratorYieldResult<ReactNode>'.
            Type 'PanelBarItem' is not assignable to type 'ReactNode'.
              Type 'PanelBarItem' is missing the following properties from type 'ReactPortal': key, children, typets(2322)

This can be observed in the demos for the PanelBar on the Kendo website, simply open the first Customisation demo in either CodeSandBox or StackBlitz and add @types/react as a dependency:

https://www.telerik.com/kendo-react-ui/components/layout/panelbar/customization/#toc-collections

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 11 Oct 2022, 02:47 PM

Hello, David,

I tried to replicate the described issue but no errors were thrown at my end when I added the `@types/react` dependency to the linked demo. Can you, please, take a look at my test sample and see whether you are able to replicate the issue at it at your end? What are the steps if so?

https://stackblitz.com/edit/react-elf7xx?file=app%2Fmain.jsx

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

David
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 12 Oct 2022, 12:38 AM

Hi Vessy,

As mentioned this is a Typescript error. I have replicated the issue in your test sample by changing main.jsx to main.tsx.

Kind regards,

David

Vessy
Telerik team
commented on 13 Oct 2022, 03:46 PM

Hi, David, thank you for the update and please, excuse me for the lapse. 

In order to avoid the thrown warning in a `.tsx` file you will need to set the `items` and `components` types explicitly:

https://stackblitz.com/edit/react-elf7xx-kjfczp?file=app%2Fmain.tsx

Tags
PanelBar
Asked by
David
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Vessy
Telerik team
Share this question
or