我想在我的 React 应用程序中使用 react-intl-redux
和 redux-form
但我在使用 时遇到了正确的事情合并 reducer
。我已经尝试了很多东西,但仍然无法弄清楚。
react-intl-redux
import { combineReducers } from "redux";
import { intlReducer, IntlState } from "react-intl-redux";
export interface IAppState {
intl: IntlState;
}
export default combineReducers<IAppState>({
intl: intlReducer
});
[ts] Argument of type '{ intl: (state: IntlState, action: IntlAction) => IntlState; }' is not assignable to parameter of type 'ReducersMapObject'. Types of property 'intl' are incompatible. Type '(state: IntlState, action: IntlAction) => IntlState' is not assignable to type 'Reducer'. Types of parameters 'state' and 'state' are incompatible. Type 'IntlState | undefined' is not assignable to type 'IntlState'. Type 'undefined' is not assignable to type 'IntlState'. (alias) function intlReducer(state: IntlState, action: IntlAction): IntlState import intlReducer
redux 形式
import { combineReducers } from "redux";
import { reducer as formReducer, FormState } from "redux-form";
export interface IAppState {
form: FormState;
}
export default combineReducers<IAppState>({
form: formReducer
});
[ts] Argument of type '{ form: FormReducer; }' is not assignable to parameter of type 'ReducersMapObject'. Types of property 'form' are incompatible. Type 'FormReducer' is not assignable to type 'Reducer'. Types of parameters 'state' and 'state' are incompatible. Type 'FormState | undefined' is not assignable to type 'FormStateMap'. Type 'undefined' is not assignable to type 'FormStateMap'. (alias) const formReducer: FormReducer import formReducer
最佳答案
尝试使用 FormStateMap 而不是 FormState。
关于reactjs - Redux 的 combineReducers 和 TypeScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51131546/