Sentry用户反馈模式未弹出onClick

时间:2018-06-24 07:05:38

标签: javascript reactjs onclick sentry react-16

我已经设置了哨兵,并且可以正常工作并正确发送错误,当前我正在使用“报告反馈”按钮制作“出了问题的页面”,问题是单击该按钮时模态不会弹出,这里代码是

index.js:

import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';

import log from 'loglevel';

import { ApolloProvider } from 'react-apollo';

import ConnectedIntlProvider from './ConnectedIntlProvider';

import GoneWrong from './components/errors/GoneWrong';
import apolloClient from './apollo/apolloClient';
import routes from './route';
import Raven from 'raven-js';
log.setDefaultLevel('trace');

class ErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      error: null,
      errorInfo: null
    };
  }

  componentDidCatch(error, errorInfo) {
    // Catch errors in any child components and re-renders with an error message
    this.setState({
      error,
      errorInfo
    });
    Raven.captureException(error, { extra: errorInfo });
    //Raven.showReportDialog();
  }

  render() {
    if (this.state.error) {
      // Fallback UI if an error occurs
      return <GoneWrong />;
    }
    // component normally just renders children
    return this.props.children;
  }
}

ReactDOM.render(
  <ApolloProvider client={apolloClient}>
    <ConnectedIntlProvider>
      <ErrorBoundary>
        <Router history={browserHistory} routes={routes} />
      </ErrorBoundary>
    </ConnectedIntlProvider>
  </ApolloProvider>,
  document.getElementById('root')
);

以下是在GoneWrong页面中包含onClick事件的按钮代码:

<button
  className="button button--blue"
  onClick={() => Raven.lastEventId() && Raven.showReportDialog()}
>

请注意,GoneWrong页面确实可以正确呈现,唯一的问题在于按钮onClick。

0 个答案:

没有答案