react-boilerplate / react-boilerplate-cra-template

:fire: Setup Create React App with React Boilerplate. Highly scalable & Best DX & Performance Focused & Best practices.
https://react-boilerplate.github.io/react-boilerplate-cra-template/
MIT License
1.87k stars 395 forks source link

Can't pass generic arguments to lazyload (loadable file)? #159

Closed cuongdevjs closed 2 years ago

cuongdevjs commented 2 years ago

Description

I've created a functional component with generic typescript and wrapped them on loadable HOC, but when I import it then typescript throws an error: Expected 0 type arguments but got 1.

Steps to reproduce

Steps to reproduce the behavior:

Please take a look at my example: https://codesandbox.io/s/purple-fog-e0b97c?file=/src/App.tsx

Thank you.

Can-Sahin commented 2 years ago

You have to cast the loadable function as well otherwise how can it be known.

Something like...


const GalleriesDnd: <T extends I_List>(props: { list: T[] }) => any = lazyLoad(....