I'm trying to pass a component to a connect
method from react-redux
. I'm getting this error:
Argument of type 'Function' is not assignable to parameter of type 'ComponentType'. Type 'Function' is not assignable to type 'FunctionComponent'. Type 'Function' provides no match for the signature '(props: never, context?: any): ReactElement<any, any> | null'.
Here's the container
const mapStateToProps = (state: globalStateType, ownProps: OffersProps) => ({
...state,
...ownProps,
});
const mapDispatchToProps = (dispatch: Function) => ({
handleSetSelectedOfferId: (
selectedOfferId: selectedOfferIdType,
): HandleSetSelectedOfferIdInterface => dispatch(setSelectedOfferId(selectedOfferId)),
});
export const OffersContainer = connect(mapStateToProps, mapDispatchToProps)(OffersComponent);
And here's the component:
export const OffersComponent: Function = ({ dataset }: OffersProps): JSX.Element[] => dataset.map(({
id, firstName, city, price, image, description,
}): React.ReactElement => (
<FlexWrapper key={id.$oid}>
<OfferContainer
id={id}
firstName={firstName}
city={city}
price={price}
image={image}
description={description}
/>
</FlexWrapper>
));
Any idea what I'm missing?
EDIT:
Removing Function
from
export const OffersComponent: Function = ({ dataset }: OffersProps): JSX.Element[] => dataset.map(({
So now it looks like this:
export const OffersComponent = ({ dataset }: OffersPropsInterface): JSX.Element[] => dataset.map(({
causes this error:
Argument of type '({ dataset }: OffersPropsInterface) => JSX.Element[]' is not assignable to parameter of type 'ComponentType'. Type '({ dataset }: OffersPropsInterface) => JSX.Element[]' is not assignable to type 'FunctionComponent'. Type 'Element[]' is missing the following properties from type 'ReactElement<any, any>': type, props, key TS2345