1

I already setup sentry and it works and sends the bugs correctly, currently i'm making a "something has gone wrong page" with a report feedback button, problem is that the modal does not pop up on clicking the button, here is the code:

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')
);

Here is the button code that has the onClick event in it in the GoneWrong page:

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

please notice that the GoneWrong page does render correctly, only problem is with the button onClick.

Mohamed Baher
  • 151
  • 1
  • 9

0 Answers0