【发布时间】:2020-12-07 10:37:28
【问题描述】:
我需要在 React 应用程序中触发错误,以确保我的 Sentry.io 已正确配置。
这是 Sentry 文档要求我执行的操作:
You can trigger your first event from your development
environment by raising an exception somewhere within
your application. An example of this would be rendering
a button whose onClick handler attempts to invoke a method
that does not exist:
return <button onClick={methodDoesNotExist}>Break the world</button>;
但是,即使我为文件禁用了 eslint,React 本身也不会让我定义 onClick 是 undefined 方法的元素。
我怎么会产生这样的错误?
【问题讨论】:
-
你不能在某个地方
throw 'Oh no an error'吗? -
谢谢你这工作完美,我应该想到它哈哈。