I
I
Ilya Pavlov2019-12-26 11:29:54
typescript
Ilya Pavlov, 2019-12-26 11:29:54

Incorrect props types for React native styled components?

When creating a styled component, it has incorrect prop types:
5e046ebaddbdf107105668.png
And if you add a type when creating StyledList :
5e046ee2b5a26949090538.png
But just FlatList works correctly:
5e04b1e40344d640099006.png
React: 16.9.0
React Native: 0.61.5
Styled Components: 4.4.1
@types/Styled Components: 4.4.1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twolegs, 2019-12-26
@twolegs

I think you need to define the type of props for the Test component:

export default class Test extends React.Component<{ item: Data }>

R
Robur, 2019-12-26
@Robur

const Item = (props: {item: Data}) => ...
and now you get two props: id and value
, and then Test also needs to be correctly typed so that props.item comes of the desired type

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question