Redux-Form 在 React 中覆盖之前的值

Redux-Form overwrite the previous value in React

我最近在做一个 React 项目,该项目是根据 redux-form@8.3.7 的输入创建的。但问题是它没有采用表格中的值。

查看redux-dev工具发现值正在替换之前的值,我在网上搜索了类似的问题也没有找到解决方案。

我的代码

减速器

import { combineReducers } from "redux";
import { reducer as formReducer } from 'redux-form'
import ocaFormFieldReducer from "./ocaFormReducers/ocaFormFieldReducer";
import stepperActiveStepReducer from "./ocaFormReducers/stepperActiveStepReducer";
import groupFieldReducer from "./ocaFormReducers/groupFieldReducer";


const reducer = combineReducers({
    ocaFormFieldReducer,
    stepperActiveStepReducer,
    groupFieldReducer,
    formReducer
});

export default reducer;
import React from "react";
import { connect } from "react-redux";
import { Field, reduxForm } from "redux-form";
import { withStyles } from "@material-ui/core/styles";

function ProductPlanning(props) {
    const { classes, formFieldLoading, formFieldData, handleActiveStep, activeStep, cancelFormProgress, setGroupFieldApiStart, groupFieldData } = props;

return (
        <div className={classes.root}>
            {formFieldLoading && <LoadingScreen />}
            <form>
                <Field name="SUrya" component="input" type="text" />
            </form>
)
}

export default reduxForm({ form: "ocaFormData" })(connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ProductPlanning)));

如果您能对此有所了解,将会很有帮助。

提前致谢。

解决方案很简单,但很笨。

在 Combine reducer 中,value reducer 应该有一个以键名作为形式的键值对。

const reducer = combineReducers({
    ocaFormFieldReducer,
    stepperActiveStepReducer,
    groupFieldReducer,
    form: formReducer
});