Converting React Component to Typescript?

Viewed 941

I'm trying to copy the example of React+Redux component to typescript: https://medium.com/@stowball/a-dummys-guide-to-redux-and-thunk-in-react-d8904a7005d3

I'm hitting a deadend with the function:

export default connect(mapStateToProps, mapDispatchToProps)(ItemList);

I'm getting an error about how it's not mappable to ItemList.

One way around this I believe is to change the class declaration to:

class ItemList extends React.Component<{proper component map}, {proper state map}> {

However if I do this because the props have now been mapped I cannot simply include ItemList as and am now expected to provide the params.

Another option might be to: (props as any).fetchData() however this feels wrong.

Is there a way around this? Am I doing React+Redux wrong in typescript?

1 Answers
Related