I can't seem to fix some typescript error I get on my react app.
Code:
const [fetchJobTitlesCall, { data }] = useLazyQuery<Jobtitles, JobtitlesVariables>(JobTitlesQuery)
useEffect(() => {
fetchJobTitlesCall({ variables: { keyword: 'Dev' } })
}, [fetchJobTitlesCall, data])
return (
<Autocomplete
onChange={(event, value) => dispatchJobTitlesFilter(value)}
multiple
id="tags-outlined"
options={data?.jobTitles} // this line throwing error
getOptionLabel={option => option.name + ` (${option.totalApplicants})`} // this line throwing error
filterSelectedOptions
renderInput={params => (
<TextField
{...params}
onChange={event => fetchJobTitles(event.target.value)}
variant="outlined"
label="Search Job Title"
placeholder="Search Job Title"
/>
)}
/>
)
Error:
Type 'Jobtitles_jobTitles | undefined' is not assignable to type 'unknown[]'. Type 'undefined' is not assignable to type 'unknown[]'.
Any idea how to fix this?