Home:ALL Converter>How to fix TypeScript function type error?

How to fix TypeScript function type error?

Ask Time:2021-01-14T02:16:57         Author:Lex2000

Json Formatter

I have TypeScript code:

const ItemsList: React.FC<any> = async () => {
  const data = await Http.get(url);
  return (
      <ul>
        {data.map(item => {
          return (
            <ItemPreview key={item.id} item={item} />
          );
        })}
      </ul>
  )
}

export default ItemsList

And got error: Type '()=>Promise<JSX.Element>' is not assingable to type 'FC'. Type 'Promise' is missing the folowing properties from type 'ReactElement<any, any>': type, props, key

Have no idea how to fix it. What type should it be instead of 'React.FC'?

Author:Lex2000,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/65707629/how-to-fix-typescript-function-type-error
yy