Estoy tratando de importar dinámicamente un icono de los iconos de reacción siguiendo las instrucciones de Nextjs, pero aparece un error.
Este es mi código:
import React, { Suspense } from 'react'; import dynamic from 'next/dynamic'; interface IconProps { name: string; } function Icon({ name }: IconProps) { const MyIcon = dynamic(() => import('react-icons/fi/index.js').then((mod) => mod[name]), {suspense: true}); return ( <Suspense fallback={`Loading...`}> <MyIcon /> </Suspense> ); } export default IconEste es el error:
Argument of type '() => Promise<IconType | React.ComponentClass<never, any> | React.FunctionComponent<never> | { default: React.ComponentType<never>; }>' is not assignable to parameter of type 'DynamicOptions<{}> | Loader<{}>'. Type '() => Promise<IconType | React.ComponentClass<never, any> | React.FunctionComponent<never> | { default: React.ComponentType<never>; }>' is not assignable to type '() => LoaderComponent<{}>'. Type 'Promise<IconType | ComponentClass<never, any> | FunctionComponent<never> | { default: ComponentType<never>; }>' is not assignable to type 'LoaderComponent<{}>'. Type 'IconType | ComponentClass<never, any> | FunctionComponent<never> | { default: ComponentType<never>; }' is not assignable to type 'ComponentType<{}> | { default: ComponentType<{}>; }'. Type 'ComponentClass<never, any>' is not assignable to type 'ComponentType<{}> | { default: ComponentType<{}>; }'. Type 'ComponentClass<never, any>' is not assignable to type 'ComponentClass<{}, any>'. Types of property 'getDerivedStateFromProps' are incompatible. Type 'GetDerivedStateFromProps<never, any> | undefined' is not assignable to type 'GetDerivedStateFromProps<{}, any> | undefined'. Type 'GetDerivedStateFromProps<never, any>' is not assignable to type 'GetDerivedStateFromProps<{}, any>'. Types of parameters 'nextProps' and 'nextProps' are incompatible. Type 'Readonly<{}>' is not assignable to type 'never'.ts(2345)¿Qué estoy haciendo mal?