我是reactjs的新手,并且正在关注udemy的基础课程.我在控制台日志中收到以下错误.任何人都可以帮我吗?
bundle.js:21818 Uncaught TypeError: _this2.props.selectBook is not a function
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.谢谢.
集装箱/书list.js
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { selectBook } from '../actions/index';
import { bindActionCreators } from 'redux';
class BookList extends Component {
renderList() {
return this.props.books.map((book) => {
return (
<li
key={book.title}
onClick={() => this.props.selectBook(book)}
className="list-group-item">
{book.title}
</li>
);
});
}
render() {
return (
<ul className="list-group col-sm-4">
{this.renderList()}
</ul>
)
}
}
function mapStateToProps(state) {
return {
books: state.books
}; …Run Code Online (Sandbox Code Playgroud)