当我从 react-router-dom 使用重定向时,我收到 TypeError: func.apply is not a function。我是 React 和 Redux 的新手

Sab*_*que 7 redirect react-redux react-router-dom

try {
    s_product = await product.save();
    res.json(s_product);
  } catch (err) {
    console.error(err.message);
    res.status(500).send("Server Error");
}
Run Code Online (Sandbox Code Playgroud)

错误代码:

TypeError: func.apply is not a function
HTMLUnknownElement.callCallback
node_
Run Code Online (Sandbox Code Playgroud)

模块/react-dom/cjs/react-dom.development.js:337

  334 |     window.event = windowEvent;
  335 |   }
  336 | 
> 337 |   func.apply(context, funcArgs);
      | ^  338 |   didError = false;
  339 | } // Create a global error event handler. We use this to capture the value
  340 | // that was thrown. It's possible that this error handler will fire more
Run Code Online (Sandbox Code Playgroud)

任何帮助真的很感激。谢谢!

Gay*_*ali 1

我在 w3 school链接到该页面时发现了这一点,当您的函数未按预期方式定义时,通常会发生此类错误

预期的方式

该网站表示您应该将参数作为数组传递。检查一下,因为如果您是否将参数作为数组传递,您的代码并没有真正提供太多相关信息