【发布时间】:2021-01-29 16:13:27
【问题描述】:
我明白了
Uncaught TypeError: Object(...) is not a function 在 useToastContainer (react-toastify.esm.js?146c:296) 在 ToastContainer (react-toastify.esm.js?146c:954) 在 mountIndeterminateComponent (react-dom.development.js?61bb:14563) 在 beginWork (react-dom.development.js?61bb:15063) 在 performUnitOfWork (react-dom.development.js?61bb:17820) 在 workLoop (react-dom.development.js?61bb:17860) 在 HTMLUnknownElement.callCallback (react-dom.development.js?61bb:149) 在 Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:199) 在 invokeGuardedCallback (react-dom.development.js?61bb:256) 在 replayUnitOfWork (react-dom.development.js?61bb:17107)
我的班级
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
export class ViewAllGraphs extends React.Component {
constructor(props) {
super(props);
this.notify = this.notify.bind(this);
}
notify() {
console.log("call notify");
toast("Wow so easy !");
}
addGraph(id) {
console.log("addGraph");
console.log(id);
console.log(toast);
toast.configure();
this.notify();
}
渲染方法返回
<img onClick={this.addGraph.bind(this, item.id)} src={`data:image/png;base64,${item.image}`} />
我是 js 新手,如何通过点击图片来调用 toast?
我的控制台日志
addGraph ViewAllGraphs.js?5897:52 6011412ff65b72973fc0f495
ViewAllGraphs.js?5897:53//它的 id ƒ toast(content, options) {
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, options)); }
ViewAllGraphs.js?5897:54 调用通知 ViewAllGraphs.js?5897:41
【问题讨论】:
标签: javascript reactjs