Я использую машинопись в моем приложении «Реакция + Редукс». Один из моих компонентов использует соединение react-redux
. Код выглядит примерно так:
import * as React from 'react';
import * as Redux from 'redux'
import compose from 'recompose/compose';
import {
connect,
} from 'react-redux';
import withContextId from '../../../../../app/containers/pageTab/contexts/withContextId';
import {
fetchContent,
} from '../../actions/workspaceActions';
import { HomePageQuery } from '../../interfaces';
interface Props extends StateProps, DispatchProps {
queryType: string,
query: string,
contextId: string,
}
interface OwnProps {
queryType: string,
query: string,
contextId: string,
}
class ContentContainer extends React.PureComponent<Props, {}> {
componentDidMount() {
const { props } = this;
props.fetchContent(props.queryType, props.query, props.contextId);
}
render() {
return (
<div>
{'Tiles Container'}
</div>
);
}
}
interface DispatchProps {
fetchContent: (query: string, queryType: string, contextId: string) => void
}
function mapDispatchToProps(dispatch: Redux.Dispatch<any>): DispatchProps {
return {
fetchContent: (query: string, queryType: string, contextId: string) => {
dispatch(fetchContent(query, queryType, contextId))
}
};
}
interface StateProps {
}
function mapStateToProps(state: any): StateProps {
return {};
}
export default compose(
withContextId,
connect<StateProps, DispatchProps, OwnProps>(mapStateToProps, mapDispatchToProps),
)(ContentContainer);
Я прочитал этот ответ и попытался отделить мои StateProps
, DispatchProps
и OwnProps
, но он все равно выдаст мне эту ошибку. Как я могу устранить эту ошибку?
[EDIT]
Я получаю queryType
и query
от его родителя как (и это обязательные реквизиты):