redux-form中的字段不可编辑

时间:2017-11-21 17:34:00

标签: reactjs redux redux-form

const FIELDS = [
{label:'Survey Title', name:'title'},
{label:'Survey Line', name:'subject'},
{label:'Email Body', name:'body'},
{label:'Recipients List', name:'emails'}
]

class SurveyForm extends Component{
    renderFileds(){
        return _.map(FIELDS,({label,name})=>{
           return (
            <Field 
                key={name}
                component={SurveyField}
                type="text"
                label={label}
                name={name}
            />
           ) 
        })

    }
    render(){
        return(
            <div>
                <form onSubmit={this.props.handleSubmit((values)=>console.log(values))}>
                    {this.renderFileds()}
                <button type="submit">Submit</button>
                </form>
            </div>
        )
    }
}

我正在使用redux-form。从redux-form导入的字段并以这种方式呈现它。屏幕上的所有内容都显示正常但是当我在输入字段上输入时,会显示不出现。该档案不可编辑。发生这种情况的具体原因是什么?

1 个答案:

答案 0 :(得分:0)

为时已晚,但我遇到了同样的问题,并通过将redux-form库的化简器添加到合并化简器中解决了该问题。

import {combineReducers} from 'redux'
import user from './userReducer'
import {reducer as formReducer} from 'redux-form';
const reducer = combineReducers({
     user,
     form: formReducer,
})
export default reducer

希望这对某人有帮助。