redux表单组件是readonly

时间:2016-06-01 05:00:52

标签: redux redux-form

我使用redux表单收到错误。它说我的文件名“搜索只是可读的”。这是一个还原形式问题还是其他一些问题?它与连接有关吗?现在我只能使用旧方式表格

import React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
var Select = require('react-select');
import {fetchAllEmails, searchUsers} from '../actions/searchAction';
import {getDashBoardDataFromEmail, clearUserState} from '../actions/dashboardAction';
var LocalToken = localStorage.getItem('token');
import _ from 'lodash';
import {reduxForm} from 'redux-form';


const Search = React.createClass({

  contextTypes:{
    router: React.PropTypes.object.isRequired
  },

  getInitialState: function(){
    return {
      value:'xyz'
    }
  },

  componentWillMount: function(){
    this.props.fetchAllEmails(LocalToken);

  },

  handleChange: function(e){
    this.props.getDashBoardDataFromEmail(LocalToken,e)
    this.context.router.push('/dashboard')
  },

  handleSearchChange(e) {
     this.setState({ value: e.target.value });
   },

   handleInputSubmit(){
     console.log('hello')
   },

  render(){
    const {fields: {someFormField, handleInputSubmit} }= this.props;

    return(
      <div>
        <h3 style={{textAlign:'center',color:'#b4b7c1'}}>Search</h3>

      <h6>Search for something</h6>
        <form onSubmit={this.handleInputSubmit}>
           <div>
             <input type="text" placeholder="Search By ..." {...someFormField} />
           </div>
        </form>
      </div>)
  }
})

Search = reduxForm({
  form:'Search',
  fields:['someFormField']
})(Search)


function mapStateToProps({ search,dashboardData,tokenValue }) {
  return {  search, dashboardData, tokenValue }
}

//functions from action
function mapDispatchToProps(dispatch){return bindActionCreators({fetchAllEmails, searchUsers, getDashBoardDataFromEmail, clearUserState},dispatch)}

export default connect(mapStateToProps, mapDispatchToProps)(Search);

2 个答案:

答案 0 :(得分:7)

如果你改变了 const Search = React.createClass({let Search = React.createClass({ 它会起作用。

答案 1 :(得分:-2)

redux-form与您的文件是否可读无关。

这是你和你的操作系统之间的。