我正在玩redux,我已经开始得到这个错误,无法解决它,我希望它有任何意义,但似乎无法找到任何信息..任何人都可以解释原因这可能表明?感谢..
代码:
type M[X] = Int
包json:
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'react-redux';
import { searchForBeers } from '../../actions/index';
class SearchBar extends Component {
constructor(props) {
super(props);
this.state = { term: ''}
this.onFieldChange = this.onFieldChange.bind(this);
this.onClickSearch = this.onClickSearch.bind(this);
}
onFieldChange(event) {
this.setState({ term: event.target.value })
console.log(this.state)
}
onClickSearch() {
console.log(this.state)
this.props.searchForBeers(this.state.term)
}
render() {
return (
<div className="col-lg-6" style={{top:20 , width:'70%'}}>
<div className="input-group">
<span className="input-group-btn">
<button onClick={this.onClickSearch} className="btn btn-secondary" type="button">Go!</button>
</span>
<input type="text" className="form-control" placeholder="Search for..." onChange={this.onFieldChange} />
</div>
</div>
)
}
}
//Container functions
function mapDispatchToProps(dispatch) {
return bindActionCreators({ searchForBeers }, dispatch);
}
export default connect(null, mapDispatchToProps)(SearchBar);