Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Argument of type 'string' is not assignable to parameter of type 'Pick'

$
0
0

Why I get this error?

Argument of type 'string' is not assignable to parameter of type 'Pick<IJobs, "name">'.  Type 'string' is not assignable to type 'Pick<IJobs, "name">'

mockData:

export const Jobs: IJobs[] = [  {    id: '1',    name: 'Trader',    available: true  },  {    id: '2',    name: 'Seller',    available: true  },  {    id: '3',    name: 'Manager',    available: false  },  {    id: '4',    name: 'Cleaner',    available: false  }];

Model:

export interface IJobs {  id: string;  name: 'Trader' | 'Seller' | 'Manager' | 'Cleaner';  available: boolean;}

Main.tsx

  const handleSetJobsAndOpenModal = (jobs: Pick<IJobs, 'name'>) => {    setCurrentJobs(jobs);  };  const scrollData = useCallback(() => (<View style={s.containerMap}>     {       Jobs.map(((el) => (<Pressable onPress={() => handleSetJobsAndOpenModal(el.name)} style={s.Btn} key={el.id}><Text>...</Text></Pressable>       )))     }</View>  ), [])

The error comes at " () => handleSetJobsAndOpenModal(el.name) <-"

What I am doing wrong ?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>