G
G
GaserV2020-10-01 20:38:32
typescript
GaserV, 2020-10-01 20:38:32

How to type redux connected & React.memo component?

How to type redux connected & React.memo component?

interface OwnProps {
    a: SomeType;
    b: SomeType;
}

interface StateProps {
    c: SomeType;
    d: SomeType;
}

type Props = OwnProps & StateProps;

const SomeComponent: React.FC<Props> = (props) => {}

const mapStateToProps = state => ({
   c: 'value',
   d: 'value'
})

const connected = connect(mapStateToProps)(SomeComponent);

const areEqual = (prev: Props, next: Props) => {...};

export default React.memo(connected, areEqual);


TS complains about areEqual:
Type 'Readonly & OwnProps>' is missing the following properties from type 'StateProps': c, d Can you tell me

how to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question