小编kev*_*nob的帖子

吐司没有呈现(反应 - 组合成分)

我正在使用react-toastify,我无法得到一个简单的吐司...

import React from "react";
import { toast } from 'react-toastify';

class MyView extends React.Component<{}, {}> {

    constructor() {
        super();
        this.state = {

        };
    }

    componentDidMount() {
        toast("Hello", { autoClose: false });
    }

    notify = () => toast("Hello", { autoClose: false });

    render() {
        return (
           <div>
             <button onClick={this.notify}>Notify</button>
           </div>
      )}
}
Run Code Online (Sandbox Code Playgroud)

package.json(在"依赖项"部分中)

"react": "^16.2.0",
"react-toastify": "^3.2.2"
Run Code Online (Sandbox Code Playgroud)

如果我调试它,我看到我的toast排队,_EventManager2永远不会得到通常从队列中发出toast的_constant.ACTION.MOUNTED事件...

/**
 * Wait until the ToastContainer is mounted to dispatch the toast
 * and attach isActive method
 */
_EventManager2.default.on(_constant.ACTION.MOUNTED, function …
Run Code Online (Sandbox Code Playgroud)

toast reactjs

9
推荐指数
5
解决办法
7930
查看次数

标签 统计

reactjs ×1

toast ×1