easymde的fileChange函数触发后引发崩溃

来源:6-5 引入 easyMDE 编辑器

刘罡

2021-05-29

您好,我根据7-4章节的引导添加了如下代码

const fileChange = (fileId, value) => {
    const newFiles = files.map(file => {
        if(file.id === fileId) {
            file.body = value
        }
        return file
    })
    setFiles(newFiles)
    
    if(!unsavedFildIds.includes(fileId)) {
        setUnsavedFileIds([...unsavedFildIds, fileId])
    }
}

当我的fileChange函数被触发后,执行到setUnsavedFileIds方法就会引发崩溃,不知道是什么原因,您能帮我看看吗?
图片描述
我的本地环境版本如下

"dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "bootstrap": "^5.0.1",
    "bootstrap-icons": "^1.5.0",
    "classnames": "^2.3.1",
    "easymde": "^2.15.0",
    "node-sass": "^5.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "react-simplemde-editor": "^5.0.1",
    "web-vitals": "^1.0.1"
  },
  "devDependencies": {
    "concurrently": "^6.1.0",
    "cross-env": "^7.0.3",
    "electron": "^12.0.9",
    "electron-is-dev": "^2.0.0",
    "wait-on": "^5.3.0"
  }
写回答

2回答

张轩

2021-05-31

同学你好 你这里使用的最新版的 react-simple-mde(5.1.0)版本,课程中使用的是 (4.1.0),新版的用法和旧版的有些出入,会导致你出现这个问题,这里建议你和课程使用一致的旧版(4.1.0),假如你使用的新版的话,可以研究一下它的写法,https://github.com/RIP21/react-simplemde-editor

0
0

张轩

2021-05-30

同学你好 可以把代码以 git 的方式提供给我一下 我在本地帮你看一下 谢谢~

0
1
刘罡
老师,你好,我这边github打开比较缓慢,所以用的是gitee https://gitee.com/guntherlau/cloud-doc.git 请您看看,谢谢🙏
2021-05-30
共1条回复

2024更新 Electron+React+七牛云实战跨平台桌面应用

开发一款自动云同步的 Markdown 文件管理软件

1253 学习 · 463 问题

查看课程