Issue
I am using NextJs and typescript and I when I pass a correctly typed prop the error i get is:
./pages/jobs.tsx:100:15
Type error: Type '{ job: jobType; key: number; handleTagClick: (tag: string) => void; }' is not assignable to type 'IntrinsicAttributes & jobType'.
Property 'job' does not exist on type 'IntrinsicAttributes & jobType'.
98 | filteredJobs.map((job) => (
99 | <JobComponent
> 100 | job={job}
| ^
101 | key={job.id}
102 | handleTagClick={handleTagClick}
103 | />
error Command failed with exit code 1.
The code is here: https://github.com/samrath2007/Internova
Solution
JobComponent
is typed as if it receives multiple arguments, but you likely meant for this to be one props object.
Currently:
const JobComponent = (job: jobType, handleTagClick: Function) => {}
What it should be:
type Props = { job: jobType, handleTagClick: Function };
const JobComponent = ({job, handleTagClick}: Props) => {}
Answered By – Nick
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0