Reputation: 12930
I am using this library: https://github.com/gitim/react-native-sortable-list ("react-native-sortable-list": "0.0.24") which does not have a type definition so I use: "@types/react-native-sortable-list": "^0.0.9".
I have the following component defined in a tsx file (typescript):
import SortableList from 'react-native-sortable-list'
import ....// others
interface Props {
tasks: ITask[]
}
export default function TasksList(props: Props) {
return (
<SortableList
data={props.tasks}
renderRow={({ active, data, disabled, index, key }) => {
return (
<View key={key}>
<Text>{data.name}</Text>
</View>
)
}}
/>
)
}
The code works (the list gets rendered fine) but I get a Typescript error:
JSX element class does not support attributes because it does not have a 'props' property.ts(2607) 'SortableList' cannot be used as a JSX component. Its instance type 'SortableList<unknown, unknown>' is not a valid JSX element. Type 'SortableList<unknown, unknown>' is missing the following properties from type 'ElementClass': render, context, setState, forceUpdate, and 3 more.ts(2786)
I don't know how to make the error go away. Any idea?
Upvotes: 0
Views: 715
Reputation: 12930
I found out that Visual Studio Code had Typescript version 4.1.5. Once I changed it to 3.9.9 the error message was gone!
Upvotes: 0