title: React.js - Handle exception caused by import in App.js
body: <p>I just added an import line to my App.js code that caused an exception which I can see in the dev tools console:</p>
  <p><code>Uncaught SyntaxError: expected expression, got '!'</code></p>
  <p>I've read this page which explains <a href="https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html" rel="nofollow noreferrer">Error Boundaries</a> But adding componentDidCatch() to my App component doesn't help because that will never be executed, as the exception is outside of the App component / App component scope.</p>
  <p>It's like I want a componentDidCatch() in my index.js but that index doesn't look like a component to me.</p>
  <p>How do I handle a js / React compilation exception gracefully when it is caused by an import statement in App.js?</p>
  <p>Maybe I could wrap my App component in AppWrapper component that implements this componentDidCatch() stuff? (or have a InnerAppComponent component) Even if that is a potential solution, I think the question is still valid and I'm wondering if there is a conventional way to deal with this problem (exceptions at the App component level)</p>
  <p>I have the same question about my index.js file: what's the convention for handling exceptions there?</p>
  <p>Edit: My exception was caused by a bad path in an import statement. I'm using Visual Studio and it works well and it was simple and easy to create this app but for this specific case, the compilation error is not displayed by in my browser when I'm debugging. I can run <code>npm run-script build</code> and then I see my error clearly. Still... is that the nature of a React app then? I'm old enough to remember when javascript didn't compile. This is a personal project but I can imagine for a large project / team, it would be preferable if a compilation error in a minor / obscure component only caused an error / exception when that page was loaded / that javascript executed? Did I miss the paradigm shift and that's just not how this works anymore?</p>