我想知道为什么点击表格行仍然会给我未定义的调度错误导致Uncaught TypeError: dispatch is not a function.我一直在关注这篇文章,试图解决问题,但到目前为止还没有成功.
ListingTable.js
import Table from 'grommet/components/Table';
import React from 'react';
import {remove, add} from '../action/ListAction';
import {connect} from 'react-redux'
let createHandlers = function(dispatch) {
let onClick = function(item) {
dispatch(add(item)) <<== undefined!!!!
};
return {
onClick
};
};
export class ListingTable extends React.Component {
constructor(props) {
super(props);
this.handlers = createHandlers(this.props.dispatch);
}
render() {
return <Table>
<tbody>
{
this.props.data.map((item, key)=>
(
// Undefined Error!!!!
<tr onClick={()=> this.handlers.onClick(item)} key={key}>
<td>{item.user_name}</td>
<td>{item.name}</td>
<td>{item.url}</td> …Run Code Online (Sandbox Code Playgroud)