javascript - 无法读取未定义的属性“列表” - 整个函数未定义
问题描述
我的错误消息告诉我,我试图调用的是未定义的,但不知道这怎么可能,因为在早期版本中,一切正常。
我有大学的网络开发教授试图帮助,以及高级设计助教
这是我们明天要介绍的团队的顶峰项目。
请,如果您知道为什么会发生这种情况,我们很乐意解决这个问题。
这是错误指向的地方:
特别是第 71 行(我将添加一个箭头)
import "./Board.css";
import React, {Component} from "react";
import { connect } from "react-redux";
import { DragDropContext, Droppable } from "react-beautiful-dnd";
import List from "./List";
import AddList from "./AddList";
//import Navbar from "./Navbar";
class Board extends Component {
state = {
addingList: false
};
toggleAddingList = () =>
this.setState({addingList: !this.state.addingList});
handleDragEnd = ({source, destination, type}) => {
// dropped outside the allowed zones
if (!destination) return;
const {dispatch} = this.props;
// Move list
if (type === "COLUMN") {
// Prevent update if nothing has changed
if (source.index !== destination.index) {
dispatch({
type: "MOVE_LIST",
payload: {
oldListIndex: source.index,
newListIndex: destination.index
}
});
}
return;
}
// Move card
if (
source.index !== destination.index ||
source.droppableId !== destination.droppableId
) {
dispatch({
type: "MOVE_CARD",
payload: {
sourceListId: source.droppableId,
destListId: destination.droppableId,
oldCardIndex: source.index,
newCardIndex: destination.index
}
});
}
};
render() {
console.log(this.props)
const {board} = this.props;
//console.log(board);
const {addingList} = this.state;
try {
return (
<DragDropContext onDragEnd={this.handleDragEnd}>
<Droppable droppableId="board" direction="horizontal" type="COLUMN">
{(provided, _snapshot) => (
<div className="Board" ref={provided.innerRef}> <---------------------------------------
{board.lists.map((listId, index) => {
return <List listId={listId} key={listId} index={index}/>;
})}
{provided.placeholder}
<div className="Add-List">
{addingList ? (
<AddList toggleAddingList={this.toggleAddingList}/>
) : (
<div
onClick={this.toggleAddingList}
className="Add-List-Button"
>
<ion-icon name="add"/>
Add a list
</div>
)}
</div>
</div>
)}
</Droppable>
</DragDropContext>
);
} catch (error) {
console.error(error.onmessage);
}
}
}
const mapStateToProps = state => ({ board: state.board });
export default connect(mapStateToProps)(Board);
感谢您为我们提供的任何见解。
解决方案
推荐阅读
- c# - 排序时 NEST 搜索元数据丢失
- html - 使用 CSS 在 Hover 上显示文本
- vue.js - vue echarts 的自动调整大小不起作用
- java - RestEasy:javax.ws.rs.ProcessingException:GZIP 输入超过最大大小:10000000
- python-3.x - 如果 while 条件循环,您不能使用 n 值的原因是什么
- javascript - Datatble 解释 javascript 数据
- excel - 我想要文件夹对话路径
- javascript - 短属性名称和长属性名称之间的映射
- cassandra - cassandra读取查询时间分析
- powerbi - 根据参数值过滤power bi报告