0

I am writing my components with a React HOC but it is giving error while using typescript for validating props. the error is as follow

Type '{ type: string; imgUrl: any; vidUrl: any; }' is not assignable to type 'IntrinsicAttributes & Pick & { children?: ReactNode;}'.

what my components look like (example):

type Props = {
type: string;
imgUrl: any;
vidUrl: any;
}
const Component = ({type,imgUrl,vidUrl}:Props)=> (
<div>.....
.....
</div>
)
export defualt withTranslation('common')(Component);

1 Answers1

0

You have to provide the correct type for component.

import { withTranslation, WithTranslation } from 'react-i18next';
import React from "react";
type Props = {
  type: string;
  imgUrl: any;
  vidUrl: any;
  }
  const Component: React.FC<Props & WithTranslation> = ({type,imgUrl,vidUrl})=> (
  <div>.....
  .....
  </div>
  )
  const withTranslationComponent = withTranslation('common')(Component);
  export default withTranslationComponent;
MjZac
  • 3,476
  • 1
  • 17
  • 28