我不确定为什么它会抱怨,因为我很确定我已经正确地连接了所有内容,我的组件类如下:
type SubmitLinkPopupProps =
SubmitLinkPopupStore.SubmitLinkPopupState
& typeof SubmitLinkPopupStore.actionCreators
& RouteComponentProps<{}>;
type SubmitLinkPopupAllProps = SubmitLinkPopupProps;// & InputSubmitLinkProps;
export class SubmitLinkPopup extends Component<SubmitLinkPopupAllProps, SubmitLinkPopupStore.SubmitLinkPopupState>
{
constructor(props: SubmitLinkPopupAllProps) {
super(props);
this.SubmitLink = this.SubmitLink.bind(this);
this.handleClose = this.handleClose.bind(this);
this.handleTextFieldChange = this.handleTextFieldChange.bind(this);
}
handleOpen = () => {
//...
};
handleClose = () => {
//...
};
handleTextFieldChange(e) {
//...
};
SubmitLink() {
//...
}
public render() {
//...
}
}
export default connect((state: Store.RootState) => state.submitLinkPopup, SubmitLinkPopupStore.actionCreators)(SubmitLinkPopup);
和reducer看起来像这样:
export const actionCreators = {
//...
}
type KnownAction = RequestSubmitLinkAction | CancelSubmitLinkAction;
const submitLinkPopupReducer: Reducer<SubmitLinkPopupState> =
(state: SubmitLinkPopupState, incomingAction: KnownAction) => {
//...
}
export default submitLinkPopupReducer;
这一切都挂在了商店里:
export interface RootState {
submitLinkPopup: SubmitLinkPopupState
}
const rootReducer = combineReducers({
submitLinkPopup: submitLinkPopupReducer,
})
const rootStore = createStore(
rootReducer,
applyMiddleware(middleware),
)
export default rootStore
这是在我之前工作的React-Redux项目中工作的,我不确定导致此问题的配置可能会丢失。
答案 0 :(得分:1)
根据错误消息,问题是RouteComponentProps<{}>;
您需要将其更改为RouteComponentProps<any>