为什么我在 react-toastify 模块中出错?

why do I get an error in react-toastify module?

我正在使用 react-toastify 弹出错误消息。为什么会出现此错误?

TypeError: Object(...) is not a function useToastContainer E:/Courses/programing/Code with Mosh/Front End/Mastering React/08 - Calling Backend Services (01h42m)/Section 8- Calling Backend Services/start/http-app/node_modules/react-toastify/dist/react-toastify.esm.js:866

删除 ToastContainer 组件后一切正常。我应该怎么做才能摆脱这个错误,为什么我会得到它?

我在这里遇到了同样的问题,我想我们都在使用最新版本的 react-toastify,但是在我将版本更改为 4.1(讲师正在使用)后它解决了!

首先,您需要:

npm uninstall react-toastify --save

然后,用4.1版本重新安装

npm i react-toastify@4.1

基于 Pelic 的回答,在卸载最新版本并重新安装 4.1 版后,我不得不重新启动 VSCode 才能让它工作!