reactjs - 从列表中删除待办事项后,我在显示待办事项内容时出错
解决方案
setTask
里面的andfilter
方法的问题handleDelete
。
const handleDelete = delt => {
const newTask = task.filter((t, i) => { // Make changes over here...
return i !== delt;
});
setTask(newTask); // Make changes over here...
};
const handleClone = index => {
let clone = task;
let Arr = clone[index];
clone.push(Arr);
setTask(clone); // Make changes over here...
};
在这里,我为您创建了工作代码
https://codesandbox.io/s/thirsty-waterfall-v7px8
希望这对你有用。
推荐阅读
- react-native - 如何在 React Native 中将 AsyncStorage 与上下文提供程序一起使用?
- mkv - 使用 Python 从 MKV 中读取第一帧
- python - 质数差距(代码战) - 过时了
- python-3.x - 当列表不在嵌套列表结构中时如何将列表元素导出到 CSV (Python)
- r - 如何从 HTML 中提取一些特定的值?
- php - 从一串没有空格的单词中获取单词
- react-native - React Native Swiper 在第一次加载屏幕时不显示幻灯片
- python - 未找到 Python 模块“pyLDAvis.gensim”
- rust - Rust、SDL2、Emscripten 和“无效渲染器”恐慌
- python - 解决具有指定间隔的三角函数 sympy Python