Skip to content

Instantly share code, notes, and snippets.

@yosevu
Last active August 8, 2017 12:51
Show Gist options
  • Select an option

  • Save yosevu/3232bbcb6928dd0e6bc1f58981683f83 to your computer and use it in GitHub Desktop.

Select an option

Save yosevu/3232bbcb6928dd0e6bc1f58981683f83 to your computer and use it in GitHub Desktop.
Index
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
// Get the element to prepend our app to from https://www.google.com.
// This could be a specific element on a website or something more general like `document.body`.
const viewport = document.getElementById('viewport');
// Create a div to render the App component to.
const app = document.createElement('div');
// Set the app element's id to `root`.
// This name is the same as the element that create-react-app renders to by default
// so it will work on the development server too.
app.id = 'root';
// Prepend the App to the viewport element in production if it exists on the page.
// You could also use `appendChild` depending on your needs.
if (viewport) viewport.prepend(app);
// Render the App.
ReactDOM.render(<App />, document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment