This has to be a simple fix, but I can't find anything explaining how you resolve this issue. I'm using Next.js and Typescript to make a component display an image and use hooks to modify said image. The problem is, when I pass in a string to the parameter that is typed as string, I get this error: Type '{ source: string; }' is not assignable to type 'string'.ts(2322)
Given this component:
const ImageToggleOnMouseOver = (source: string) : JSX.Element => { ... }
When I try to use it, like so, I get the above error:
return (
<div>
<ImageToggleOnMouseOver source='/heads_up.jpg' />
</div>
);
When provided as source: any it works fine, but shouldn't string also work since I'm expecting to pass in a string after all?
(props)(the param name should not matter) which are of type any and useprops.sourceor use({source: string})instead