Skip to content

Instantly share code, notes, and snippets.

@baluragala
Last active October 10, 2017 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baluragala/28cc603daaafa3bc69196d414878fdc8 to your computer and use it in GitHub Desktop.
Save baluragala/28cc603daaafa3bc69196d414878fdc8 to your computer and use it in GitHub Desktop.
Index component that renders React component to DOM
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import TryCatch from './TryCatch'
ReactDOM.render(
/*
App component is wrapped inside TryCatch( error boundary component ). Hence any error in the App or children DOM tree,
error boundary component will handle it, say the DOM tree is something like App->ProductList->ProductItem->Rating, if error
occurs in Rating and if there are no other error boundaries in the heirarchy, error will bubble upto TryCatch and fallback UI will
rendered
*/
<TryCatch>
<App/>
</TryCatch>
, document.getElementById('root'));
registerServiceWorker();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment